Results 1 to 6 of 6

Thread: ImageIcon class of java

  1. #1
    Join Date
    Jan 2008
    Posts
    1,521

    ImageIcon class of java

    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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);
      }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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)

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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);
      }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    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)

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. KeyboardFocusManager class of java
    By Gokul20 in forum Software Development
    Replies: 4
    Last Post: 05-03-2010, 03:38 PM
  3. JDesktopPane class of java
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 08:14 AM
  4. What is TransferSupport Class in Java?
    By DANIEL 602 in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 06:54 AM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,042,442.23504 seconds with 17 queries