Results 1 to 3 of 3

Thread: change image icon?

  1. #1
    AndersonDiaz is offline Senior Member
    Join Date
    Dec 2009
    Posts
    311
    Rep Power
    3

    Default change image icon?

    I am last year BSc(I.T) student. I am doing one live project. In that project I have to change JFrame image icon. I tried different techniques but not any of them worked out. Can anybody tell me how to change JFrame image icon? Thanks in advance.

  2. #2
    TaylorRyan is offline Senior Member
    Join Date
    Dec 2009
    Posts
    307
    Rep Power
    3

    Default

    Using following program you will able to learn How to change JFrame image icon. In the following program I have use rame.setIconImage(Toolkit.getDefaultToolkit().get Image("test.jpg")); method to change JFrame image icon. You have to just add javax.swing.* class to do this.

    Code:
    import javax.swing.*;
    import java.awt.*;
    public class SettingIconFrameEg
     {
      public static void main(String[] args){
        JFrame frames = new JFrame("Set an image for a frame");
        frame.setIconImage(Toolkit.getDefaultToolkit().getImage("test.jpg"));
        frames.setDefaultCloseOperation(JFrames.EXIT_ON_CLOSE);
        frames.setSize(400,250);
        frames.setVisible(true);
      }
    }
    Last edited by TaylorRyan; 02-09-2010 at 04:15 PM.

  3. #3
    ThomasBarnes is offline Senior Member
    Join Date
    Dec 2009
    Posts
    303
    Rep Power
    3

    Default

    Try to understand following code which given below. In the following code I use mageIcon loadImageIcon(String filenames) method to receive image from one folder and assigning to Jframe.

    Code:
    public static ImageIcon loadImageIcon(String filenames) {
    
        URL urls = Configs.class.getClassLoaders().getResources( IMAGE_DIR + filenames);
        if (urls == null) {
            System.err.println("image does not exits" + filenames);
            return null;
        }
        ImageIcon icons = new ImageIcon(urls);
        return icons;
    }

Similar Threads

  1. How to Change the Size of a Shortcut Arrow Icon in Vista
    By Davisricky in forum Windows Vista
    Replies: 0
    Last Post: 05-17-2010, 05:29 PM
  2. Making My Computer icon as first icon in XP
    By OrtizCooper in forum Windows XP
    Replies: 2
    Last Post: 03-30-2010, 02:12 PM
  3. Change an Icon for a Removable Drive in Vista
    By JacksonPerez in forum Windows Vista
    Replies: 0
    Last Post: 03-15-2010, 06:00 PM
  4. Network icon taskbar icon not showing right
    By andressa143 in forum General Networking
    Replies: 3
    Last Post: 08-08-2009, 01:17 PM
  5. Change a folder icon (XP)
    By qeintine641 in forum Windows XP
    Replies: 0
    Last Post: 03-31-2009, 06:09 AM

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
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48