Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , , ,

Sponsored Links


ImageIcon class of java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 19-02-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,507
ImageIcon class of java

Sponsored Links
Hello Friends,

I am IT student and currently studying java programming. In which I want to be aware about the ImageIcon class of java. I have to use this class in my java project. But unfortunately I don't have enough knowledge about ImageIcon class. So please help me to know about the ImageIcon class of java. If possible then give suitable example for ImageIcon class. I would greatly appreciate your any help.

Reply With Quote
  #2  
Old 19-02-2010
Member
 
Join Date: May 2008
Posts: 2,000
Re: ImageIcon class of java

A ImageIcon class used for an implementation of the Icon interface that paints Icons fromImages. Images that are created from a URL or filename are preloaded using MediaTracker to monitor the loaded state of the image. The ThumbnailAction class, an inner class in IconDemoApp.java, is a descendant of AbstractAction that manages our full size image icon, a thumbnail version, and its description. When the actionPerformed method is called the full size image is loaded into the main display area.
Reply With Quote
  #3  
Old 19-02-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,990
Re: ImageIcon class of java

Hi friend,

I suggest you to go through the following example of 'ImageIcon class'
Code:
import javax.swing.ImageIcon;

public class ImageIconDM {

  public static void main(String[] ank) {
    JFrame clW = new JFrame();
    clW.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ImageIcon icon = new ImageIcon("yourFile.gif");

    Image normalImage1 = icon.getImage();
    Image grayImage1 = GrayFilter.createDisabledImage(normalImage1);
    Icon warningIcon1 = new ImageIcon(grayImage1);
    JLabel warningLabel1 = new JLabel(warningIcon1);

    JLabel label03 = new JLabel("Warning", icon, JLabel.CENTER);

    clW.add(warningLabel1,"Center");
    clW.add(label03,"South");

    clW.setSize(400, 200);
    clW.setVisible(true);
  }
Reply With Quote
  #4  
Old 19-02-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,278
Re: ImageIcon class of java

Please study following Constructors of ImageIcon class:
  • ImageIcon(URL lctn, String description1)
  • ImageIcon(URL lctn)
  • ImageIcon(String filename1, String description1)
  • ImageIcon(String filename1)
  • ImageIcon(Image image1, String description1)
  • ImageIcon(Image image1)
Reply With Quote
  #5  
Old 19-02-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,382
Re: ImageIcon class of java

Example of ImageIcon class:
Code:
import javax.swing.ImageIcon;
import javax.swing.border.Border;

public class ImageIconMain {
  public static void main(String args[]) {
    JFrame f05 = new JFrame("Label Demo");
    f05.setLayout(new FlowLayout());
    f05.setSize(300, 360);
    f05.setDef05aultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ImageIcon myIcon = new ImageIcon("myIcon.gif05");
    
    JLabel label01= new JLabel("A def05ault label", myIcon, JLabel.LEFT);
    Border border1 = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border1);
    f05.add(label01);

    f05.setVisible(true);
  }
}
Reply With Quote
  #6  
Old 19-02-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,371
Re: ImageIcon class of java

Hi,

Bwlow I have given some important methods of ImageIcon class:
  1. setImageObserver(ImageObserver obsrvr)
  2. setImage(Image img)
  3. setDescription(String description1)
  4. paintIcon(Component c, Graphics gp1, int x1, int y1)
  5. loadImage(Image img)
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "ImageIcon class of java"
Thread Thread Starter Forum Replies Last Post
Converting java class to java bean class Ucchal Software Development 6 09-08-2010 10:24 AM
How to use Image class in java? Gajananvihari Software Development 4 27-02-2010 09:11 AM
AbstractButton class of java Owen Fernandes Software Development 5 22-02-2010 07:17 AM
JTree class of java Owen Fernandes Software Development 5 13-02-2010 07:23 AM
Java Programming Language Basics: Reflection Basics and Class Class mayuri_gunjan Guides & Tutorials 6 29-08-2005 12:04 AM


All times are GMT +5.5. The time now is 02:40 AM.