Results 1 to 5 of 5
Thread: [SOLVED] Setting a icon
- 02-16-2009, 07:06 PM #1
[SOLVED] Setting a icon
I'm using blueJ, and i have created a simple application which creates a frame and gives it a title.
I am wanting to set my own icon to this application, so that the icon can be seen to the right of the frame title, when both onscreen and minimized.
For example you see the fox icon in any Firefox window when it is both on the screen or minimized.
Below presents my current code. This code produces no errors. However the default icon (the cup one) appears, rather than the one i specified.
(Yes, my icon is in the images/ directory.)
Any help or guidance would be great, thanks.Java Code:import javax.swing.*; import java.awt.*; public class IconApplication { public static void main(String arg[]) { //create JFrame with title JFrame frame = new JFrame("Application with a custom icon"); //set frame size too 300, 300 frame.setSize (500, 150); //set frame default close operation frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); //Cannot change the frames size frame.setResizable(false); //centers the frame frame.setLocationRelativeTo(null); // Set icon Image icon = Toolkit.getDefaultToolkit().getImage("images/icon.ico"); frame.setIconImage(icon); //set frame visiblitiy to true frame.setVisible(true); } }
- 02-16-2009, 07:33 PM #2
I think you mean to the left not to the right. I have wondered also how to change it from the java logo. It is possible because when I load Netbeans, for a second its icon is the java logo, but then it switches to the NetBeans logo. I'm not sure how you do it though.
-MK12Tell me if you want a cool Java logo avatar like mine and I'll make you one.
- 02-16-2009, 07:41 PM #3
yeah i did, couldnt edit post due to post count and didnt want to double post.
Surely its possible otherwise every application coded in java would have the same icon.
- 02-16-2009, 07:45 PM #4
oh
Yeah, I didn't mean that I thought is wasn't possible, I just meant I knew for sure it was.. even though its obvious it would have to be anyway.... never mind.
-MK12
EDIT: Other senior members or mods: How come I'm a senior member now? Does it just mean I exceeded a certain amount of posts?Tell me if you want a cool Java logo avatar like mine and I'll make you one.
- 02-16-2009, 08:41 PM #5
Similar Threads
-
Applet Icon
By arimakidd in forum Java AppletsReplies: 4Last Post: 04-30-2009, 04:05 AM -
Problem in setting icon for JFrame!
By pranav13 in forum AWT / SwingReplies: 8Last Post: 11-04-2008, 05:24 AM -
set.Icon
By safiya in forum NetBeansReplies: 2Last Post: 10-17-2008, 06:46 PM -
icon
By amith in forum AWT / SwingReplies: 1Last Post: 05-16-2008, 07:34 PM -
To add an icon to my project
By Albert in forum AWT / SwingReplies: 1Last Post: 07-13-2007, 03:14 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks