Questions tagged [imageicon]

An ImageIcon is an implementation of the Icon interface in Java Swing.

An ImageIcon is an implementation of the Icon interface in Java Swing. ImageIcon paints an icon from GIF, JPEG, or PNG files1 2 or a java.awt.Image.

  1. Sources for images might be constructed from
    • File (rarely useful)
    • String denoting the path to a File (N.B. often leads to the 'loading resource error mentioned below').
    • URL (typically used for )
    • Image
    • InputStream that is from/of an image.
  2. The image formats you can rely on the J2SE to handle is as above, JPG, PNG & GIF. OTOH Java based image I/O formats are provided by Service Provider Interface. Any particular JRE might support more formats.

Resources

FAQ

  1. What's an easy way to display an Image in Java/Scala?
  2. Loading Icon resource error
  3. How to turn ImageIcon to gray on Swing
  4. Use animated GIF in desktop application
  5. Getting label icon to appear above text
  6. Image Scaling
1040 questions
-2
votes
2 answers

Displaying an alternative text when meet wrong location

I am working for Swing accessibility. I am using ImageIcon. I need to place the alternative textual information when image URL is broken.
-2
votes
2 answers

How to find JLabel that was clicked and show ImageIcon from it?

Here is my code. I want to know which l was clicked and then in a new frame, display that ImageIcon. The e.getSource() is not working... final JFrame shirts = new JFrame("T-shirts"); JPanel panel = new JPanel(new GridLayout(4, 4, 3, 3)); for (int i…
jjj
  • 27
  • 8
-2
votes
1 answer

Creating multiple JToggleButton with indivdual ImageIcon

ImageIcon img_1 = new ImageIcon("src/menu/btn_1.jpg"); ImageIcon img_2 = new ImageIcon("src/menu/btn_2.jpg"); ImageIcon img_3 = new ImageIcon("src/menu/btn_3.jpg"); ImageIcon img_4 = new ImageIcon("src/menu/btn_4.jpg"); ImageIcon…
Zainau
  • 95
  • 4
  • 13
-2
votes
1 answer

How to show image in JLabel?

I am having problem in displaying an image in JLabel with directories received through file dialog. But to check the problem I checked with a static directory. But the problem is persistent. How to show an image in a JLabel? public class lib…
-2
votes
1 answer

How Do I Set An Icon For JLabel

I want to set an icon for a jlabel, can somebody give me example syntax I have tried this : JLabel icon = new JLabel(); ImageIcon chromo = createImageIcon("res/icon.png"); panel.add(icon); icon.setIcon(chromo); After I tried this the label didn't…
-2
votes
1 answer

How can i change an image to another image by clicking in it in java

I want to change the icon used by imageicon in this code to another one by clicking in that imageicon. Can anybody help me please? what can i do in this code?? and i want it to also make fall down if the bottom is filled with white color.If one user…
-2
votes
1 answer

Instead of the picture it shows me the x.png inside the cell, how can i make it SHOW the actual picture or put some background color when value=="1"

package dmaze2; import java.awt.Dimension; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; public class Dmaze2 extends JPanel { JTable jt; …
-2
votes
2 answers

Unable to get resources using getResource()

I'm trying to get an image to use in a JButton, with the code: ImageIcon imageIcon = new ImageIcon(MineSweeper.class.getResource("C:\\Users\\___\\Documents\\GitHub\\____\\myImage.png")); buttons[x][y].setIcon(imageIcon); I know the file exists…
-2
votes
1 answer

Invalid file reference, where am i going wrong?

Whenever i try to draw an image with paintComponent and ImageIcon i get a NullPointerException from an unknown source, then pointing to my image getter and the thread start. Image getter ImageIcon image = new…
-2
votes
2 answers

How to flip and save Image

My Image declaration: ImageIcon imageIcon1 = new ImageIcon(main.class.getResource("image1.png")); Image image1 = imageIcon1.getImage(); How do I take image1, flip it along it's vertical axis and save it as another image? I have googled and every…
-2
votes
2 answers

How to free memory allocated by ImageIcon? I have a infinite loop with "new ImageIcon" and i need free each image after display.

How to free memory allocated by ImageIcon? I have an infinite loop with "new ImageIcon ..." and i need to free the memory allocated by each image after displaying it on the screen. The display interval between images is 200 ms. Does anyone have a…
Nilton
  • 9
  • 6
-2
votes
1 answer

Null pointer exception when drawing an image?

Im trying to draw an image in java. It was working before I created a separate class just to store the images. But now I get Null pointer exception. Main class: Image image; Images images; // class object public void paint(Graphics G){ image =…
redundant6939
  • 153
  • 3
  • 5
  • 16
-3
votes
1 answer

java maven imageIcon

i am using maven in netbeans and i have a frame where i want to add a logo to. in the design part of the jframe i can see the logo but when i run the app it gives me an error saying that the location is null. however my code works without the…
-3
votes
1 answer

Change size JLabel (ImageIcon) on Java

I have this code: http://pastebin.com/N7XnK8XH The result is a large display panel, but the picture still is small, does not scale I've tried everything Please help me
-3
votes
1 answer

Inserting logo in the corner of JFrame

Possible Duplicate: How to change JFrame Icon I want to put Logo or some icon on the corner of window in my Java desktop application. How to do that?
Kumar
  • 955
  • 5
  • 20
  • 50
1 2 3
69
70