I am trying to make a game with an image on it, and I have one class that gets the image and the other is the game. When I run the program, it just shows my image on a gray JFrame. This leads me to think the image might be covering my whole game, which is weird because it is a mostly transparent image. I have tried resizing it and everything but I don't know what to do..
I'm trying to open an image within a JFrame but the image doesn't show. The directory path is correct. The JFrame opens perfectly but no image is showing.
JFrame frame = new JFrame("IMAGE"); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon image = new ImageIcon("images/main.jpg"); JLabel label = new JLabel("", image, JLabel.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add( label, BorderLayout.CENTER ); frame.setVisible(true);
I've recently decided to learn Java on my own using internet material such as forums, blogs and you tube. Ive never programed before but through some research I concluded that Java is going to be on the mid spectrum of difficulty as far as verbiage goes. I ma in no way implying that Java is easy but instead closer to spoken English that c++ if my research is correct. So here is my attempt at a basic program where I click a button and it will make an image appear. Not sure where Im falling short
package clicktoimage; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Clicktoimage extends JFrame { private JLabel label; private ImageIcon image;
How to drag an image beyond the JFrame limits. In Netbeans, when you drag a Java file editor pane out of the main application frame and onto a second monitor, Netbeans provides a semi-transparent image of the pane you're dragging. I would like to reproduce this effect in my own code. I've been able to do this in a test program (code below) using a glass pane, but cannot figure out a good way to get the image to drag beyond the limits of the main application frame. I looked at the DragnGhostDemo from SwingHacks but it has the same limitation. How this could be accomplished?
In the test application below, click on on the button and drag it's image across the application frame.
I implemented the gray scale filter and the convolution filter . If I apply before the grayscale filter convolution and then I can not see the picture, I see pretty much the JPanel that should contain the image. The two filters separately functioning correctly
Code filter grey scale
public BufferedImage greyScale(BufferedImage originalImage) { BufferedImage destImg = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB); int alpha, red, green, blue; for (int x = 0; x < originalImage.getWidth(); x++) { for (int y = 0; y < originalImage.getHeight(); y++) { int pixel = originalImage.getRGB(x, y);
I am trying to make movingLabel move to a different JPanel each time the JButton is clicked. I can see that the random integer is changing each time the button is clicked, but the movingLabel wasn't doing anything. I noticed that if I click the button and then resize the JFrame with my mouse, it shows in the correct panel. Is there something I am missing, or is there a way to make it automatically display in the correct panel without having to manually resize the JFrame each time? I was thinking that I could add something that resizes the window slightly each time the button is clicked to show it, but I don't think that is probably the "right" way to do it.
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Random; public class JMovingFrame extends JFrame implements ActionListener
This is an old project that I had working probably 2 years ago. Since I reopened it the only thing I have changed is the database location. This is a very basic project I did to dip my toes in to Java. I'm going to add it to my portfolio but just to clarify I am not a Java developer so this is mainly there to show that I am not completely blind when it comes to Java.
Errors when I click the button that launches the JFrame:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 6 >= 6 at java.util.Vector.elementAt(Unknown Source) at javax.swing.table.DefaultTableModel.getValueAt(Unknown Source) at javax.swing.JTable.getValueAt(Unknown Source) at javax.swing.JTable.prepareRenderer(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
[Code]...
It will launch the window but it will be blank. If I resize the window it will show me the headers. If I click below the headers were the data should be, it will show me the data.
Since it has been so long the only thing I can think of is some of the code has become antiquated. As I said, this was working originally. I just fired it up again to take some screenshots for my portfolio.
I would like to reopen the following discussion: Show SVG-Image in WebView (JavaFX 8)
In our IDE (Eclipse Luna) running with jdk1.8.0_25 we load a html page into the webengine. The html page contains <img> tags with '.png' and '.svg' as src. Everything looks fine.
But if we execute the programm with java -jar, the WebEngine doesn't display the svg-files. Instead it shows the 'File not find'-Icon. The .png files still work
The files are definitly included into the jar and will be displayed if we link to them via <a href="someSvg.svg"></a>
I have been trying to make a game lately, but I can't seem to work out how to get an image to display on my JFrame. I have tried everything, copied different codes of the internet, but nothing works. Here is my code of the GUI:
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GUI extends JFrame implements Runnable, ActionListener { JButton start = new JButton("Start nieuw spel"); JButton instellingen = new JButton("Instellingen"); public GUI() {
I use Canvas, Graphics & JFrame, but not JPanel, how do I add an Image? To see my code: [Java] package pack.script.game; import java.awt. BorderLayout; import java.awt.Canv - Pastebin.com
What do I need to add, or where can I find information on how to add an image? Can I add an image using Graphics? I will import any utils, swings or awts needed. But I don't want to change my code too much.
I am looking for a solution that will allow me to use a custom background image to replace the JFrame window. I am able to add a background Image, however I am not able to remove the "white" that is supposed to be transparent.
For example; if the image was shaped like a bird with transparent background (.PNG), I would like that to be put on the JFrame. Usually it will be a square with the image in the middle with white background, which I am unable to remove.
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.