ImageIcon « Icon Image « Java Swing Q&A





1. java imageicon size    stackoverflow.com

i am a totally new programmer here and i have something to ask, i have uploaded a picture into my GUI which displays on a Label, but the label dimension is set ...

2. Swing & Batik: Create an ImageIcon from an SVG file?    stackoverflow.com

Simply put, I'm looking for a way to make an ImageIcon from an SVG file using the batik library. I don't want to have to raster the SVG to disk ...

3. PNGException "crc corruption" when attempting to create ImageIcon objects from ZIP archive    stackoverflow.com

I've got a ZIP file containing a number of PNG images that I am trying to load into my Java application as ImageIcon resources directly from the archive. Here's my code:

import ...

4. what is maximum size of image we can use with ImageIcon?    stackoverflow.com

I am setting image to Label and before that I am creating ImageIcon Object ImageIcon icon=new ImageIcon(PathToImage,"Image"); jLabel.setIcon(icon); when image size exceeding 4 MB i am getting "java.lang.OutOfMemoryError: Java heap space" Is this ...

5. ImageIcon loading getting slower and slower    stackoverflow.com

In my java GUI application, I have some components that need to scale repeatedly, and I am doing this with the following code:

Image newImage = myimage.getScaledInstance(width, height, Image.SCALE_REPLICATE);

ImageIcon newIcon = new ...

6. Java - delete an ImageIcon?    stackoverflow.com

Is there any way to easily delete an ImageIcon completely from the screen? I can't find one anywhere.

    ImageIcon image = new ImageIcon("candle.gif");
    image.paintIcon(this, g, ...

7. Unable to draw a simple image using JComponent    stackoverflow.com

I'm using netbeans IDE to practice some Java basic code. But I'm unsuccessful to draw a PNG image. Below is my code,

package JavaApplication1;

import javax.swing.*;
import java.awt.*;

class MyCanvas extends JComponent
{
    ...

8. Curious why my image isn't showing up    stackoverflow.com

Just using the paint method and my image won't show up initially. Once I minimize the java window and resize it, the image shows up. Is there any code ...

9. Java - Draw text in the center of an image    stackoverflow.com

I need to write a text in the center of an image, the problem is that the text is not always the same... The code I'm using is here:

   ...





10. ImageIcon not loading    stackoverflow.com

So I am trying to make a small game for a project in college. I have an image class that loads the images etc. I know this class works because I ...

11. Resizing an image in swing    stackoverflow.com

I have snippet of code that I am using for the purpose of resizing an image to a curtain size (I want to change the resolution to something like 200 dpi). ...

12. How can I get an Image and then Use it to make an ImageIcon in Java GUI    stackoverflow.com

I am trying to make a card game and Am running into an issue with my getImage() function. I have an String Array of the Cards ex:

private static String[] hearts = {"ah.gif","2h.gif","3h.gif","4h.gif","5h.gif","6h.gif","7h.gif","8h.gif","9h.gif","th.gif","jh.gif","qh.gif","kh.gif"};
My ...

13. Compare two image icons?    stackoverflow.com

I ran into an issue while I'm making a 4 player chess game. I am unable to see if two ImageIcons are the same. I have four arrays for the red, ...

14. Resize ImageIcon    coderanch.com

15. ImageIcon in array or single?    coderanch.com

16. Image or ImageIcon?    coderanch.com





17. ImageIcon    coderanch.com

18. ImageIcon corruption?    coderanch.com

We had a strange thing happen to our application and I think it is a Java bug. The swing application with toolbar icons and other images was left running over night - during that time something may have happened where the resources got low and the gui (probably) started to redraw all haywire like it does - in the morning some ...

20. ImageIcon problem    coderanch.com

Yeah, that's right... I also went back and tested out reading from a zip file locally and trying to read from a zipfile that doesn't exist throws a java.util.ZipException, so that would probably happen if the applet couldn't find the zip file due to a proxy problem, too... If you override a component to paint the image in its paintComponent() method, ...

21. ImageIcon trouble    coderanch.com

Suggestion: change the line: URL url = ShowingAnImage.class.getResource(fileName); to: URL url = ShowingAnImage.class.getClassLoader().getSystemResource(fileName); Then regardless of what package ShowingAnImage belongs to, the file will be found. (It will still work without a package being specified) For instance [B]package test;[/B] import java.awt.*; import java.io.*; import java.net.*; import javax.imageio.ImageIO; import javax.swing.*; public class ShowingAnImage { public static void main(String[] args) { Image image ...

22. Working with ImageIcon.    coderanch.com

23. Images for ImageIcon.    coderanch.com

24. Funny ImageIcon loading    coderanch.com

Hello there, can someone help me with this..? I have an application that loads a jpg "img.jpg" that resides in folder called "ImgFolder". The application itself is in another folder called "classes". "ImgFolder" and "classes" both have the same parent folder, called "MyFolder". .../.../MyFolder/ImgFolder/img.jpg .../.../MyFolder/classes/MyApplication.class The application contains code like this: JButton imageBut = new JButton(); imageBut.setIcon(new ImageIcon( " //.../.../MyFolder/ImgFolder/img.jpg " ...

25. How to extend ImageIcon class effectively    coderanch.com

import javax.swing.*; import java.awt.*; import java.net.URL; public class SingleCard extends ImageIcon { private int suit, value; public SingleCard() { super(); } public SingleCard( URL pic, int a, int b) { super(pic); suit = a; value = b; } public int getSuit() { return suit; } public int getValue() { return value; } }

26. ImageIcon performance    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

27. Creating an ImageIcon    coderanch.com

28. ImageIcon    coderanch.com

Rather than starting at the ImageIcon, I would try to start with the source of the image: if you are loading the image from a file or URL, you can read it as a BufferedImage, and at that point it is easy to manipulate any way you wish: import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.io.*; import java.net.*; import javax.imageio.*; import ...

29. Image or ImageIcon to byte []    coderanch.com

30. ImageIcon NullPointerException    coderanch.com

Thanks for the response! I haven't tried that yet, but did find something interesting (and weird). I tried all of my other images that I had in Eclipse and they all worked with the code that I currently have. I could not think of anything else, so just for craps and giggles, I renamed the image from cancel.jpg to redx.jpg, then ...

31. Append a String to an ImageIcon    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

32. imageIcon    coderanch.com

33. Image or ImageIcon?    coderanch.com

34. trouble displaying ImageIcon    coderanch.com

I have a piece of code from a book I'm working with. I haven't adjusted the code at all and so am surprised that it isn't working properly out of the box. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class jlabel { static JFrame frame = new JFrame("Example"); public static void main(String[] args) { ImageIcon icon = new ImageIcon("star.gif"); JLabel jl ...

35. ImageIcon vs Image    coderanch.com

36. Rotating an ImageIcon    coderanch.com

Hello Everyone! Thank you for taking the time to look at my thread. I have an assignment to do on concurrency. That's fine, however I face an initial hurdle. This assignment is based on the dining philosophers problem. I can change the number of philosophers at present by changing the appropriate variable in the code. I'm supposed to rotate the philosophers ...

37. GIF's and IMAGEICON's...    coderanch.com

Hello everyone. I have this issue: I set an imageIcon on a JButton component. This imageIcon is an animated .gif I made. When I run my program, the first time I click the animation is properly executed. Afterwards, when I click on other buttons that are present on my grid they skip to the last frame. Here's the method that is ...

38. ImageIcon not working    coderanch.com

public class ImageD extends JFrame implements ActionListener { JFileChooser fc; JLabel imglabel; JTextArea imgarea; JButton imgload; ImageIcon myimage; ImageD(String s) { setTitle(s); setSize(500,500); setLayout(new FlowLayout()); imgload = new JButton("Load ImG"); imgload.addActionListener(this); imglabel = new JLabel(); imgarea = new JTextArea("uneditable",10,10); imgarea.setEditable(false); add(imgload); add(imglabel); add(imgarea); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource()==imgload) { fc = new JFileChooser(); FileNameExtensionFilter filter = new ...

39. NullPointer on loading ImageIcon    coderanch.com

40. ImageIcon's not displayed when created a executable Jar.    coderanch.com

I have created a Java Swing application with an Icon Image and executed in Eclipse it's showing Icon Image but when I exported this application as a Runnable JAR then application is working fine but Icon Image is not displayed. I am struggling ... could you please let me know the problem? Regards...

42. Converting BufferedImage Into ImageIcon    java-forums.org

How do I do it? I have a resize function that yses BufferedImage but I need an ImageIcon to put it into a JLabel? ImageIcon image = new ImageIcon("src/backgroundimage.jpg"); BufferedImage resizedimage = resize(image,width,height); //error! type conversion JLabel logo = new JLabel( resizedimage ); content.add(logo, BorderLayout.CENTER); //this class resizes the image public BufferedImage resize(BufferedImage image, int width, int height) { BufferedImage resizedImage ...

43. ImageIcon won't load my image    java-forums.org

44. Issue in reading .bmp file using javax.swing.ImageIcon    java-forums.org

Hi Guys, I am facing an issue while reading .bmp files using ImageIcon. Its working for jpeg and png. below is the code with a p.s.v.m(the main class) and follows the utility class which is helping in some read and write operation of the image files. the main class Java Code: import java.io.File; import java.net.FileNameMap; import java.net.URLConnection; public class thumbnailGenerator { ...

45. javax.swing, ImageIcon question    forums.oracle.com