Placing an Icon in the Title bar.
Hello,
i am unable to set an icon before the title in the title bar.
i am using jdk1.4.
could someone plz tell me how to do this.
i have tried the setFrameIcon method...but it only works for internal frames...not for JFrame.
By default it is the tea cup and saucer icon( well, that is what it is right?)...how can i replace this with my own icon?
setIconImage ( new ImageIcon ( "image.gif" ).getImage () );
put "image.gif" in the same directory as the .class
Similar Messages
-
How to replace the icon in the title bar and minimized window
I am not sure if this is a Swing question. But since nobody answered it in the Java Programming forum, let me place it here:
I would like to set my own icon in the title bar and in the minimized window of my java application, replacing the java coffee cup icon.
I am using:
frame.setIconImage(new ImageIcon("image.gif").getImage())
as was suggested previously in the Java Programming forum at:
http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5212059
This does create the icon in both places. However, it only works when I run the program from JBuilder 2006. It doesn't work if I run the program from the .jar or the .exe file.
How can I make it work for my .jar and .exe file?
Please help! Thanks!It doesn't work if I run the program from the .jar...working example for a .jar
import javax.swing.*;
import java.awt.*;
class Testing
public void buildGUI()
JFrame f = new JFrame();
Image img;
try
java.net.URL url = new java.net.URL(getClass().getResource("Save.gif"), "Save.gif");//correct capitalization required
if (url != null)
img = javax.imageio.ImageIO.read(url);
f.setIconImage(img);
catch(Exception e){}//do nothing - default will display
f.setSize(200,200);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
public static void main(String[] args)
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new Testing().buildGUI();
} -
Changing icon in the title bar
Hi all,
I've seen that applications like NetBeans have custom icons in the title bar of the application (instead of the standard Java Cup). How can I do the same? (i.e. customize the icon).
Thanks in advance!One issue to be aware on Windows is that the icon you set is used both on the title bar (16x16) and when you <alt> <tab> between apps (32x32 or 48x48 on XP). This means that if you create a 16x16 icon it will look kind of chunky when you <alt><tab>. At work we get our art department to create a 48x48 icon that scales down to 16x16 well, a non trival task.
IL -
How to add an icon in the title bar,next to the maximize and minimize icons
I need to add an icon ( help icon; ?) in the JInternalFrame� title bar. Anyone could help me????
Thankshave you get the answer ?? on how you add an icon to the title bar?? ...
if you do please inform me..
thanks -
i use imac, lion.
by accident, i discovered that, clicking on and dragging the icon at the left of the title bar (actually within the title bar to left of file name), i can sometimes open the
image in ACR, as hosted by BRIDGE (which is not running. i do not use bridge).
sometimes the image will be duplicated following this dragging of icon, the new duplicate lying atop the image of the background layer, in the same window, and shows the diagonal bars awaiting resizing. if i just click the ("checkmark") in the options bar to accept this new layer, or, if i press enter, i am looking at a new layer, which is a duplicate of the background layer. this new layer is a "SMART OBJECT", and functions as such.
this happens only with JPG and TIF files, not with RAW. i have ACR prefs set to open all supported jpg and tif files.
i should note that none of this occurs if the image has been edited in any way. in fact, after any edit the icon in the title bar is not movable.
i am having some difficulty describing a simple and quick process. i don't know if this is a bug, a feature, or the result of too much RED BULL! i Just reread post and it does seem delusional.
can anyone help?it seems to work with or without the shift key.
I work with OS 10.6.8 and you are right that it works without shift, too.
My surmise is that the title bar’s icon of non-dirty files (files that have no History steps save the Open-step or have just been saved) behaves like the file’s icon in the Finder as the behaviour seems to be exactly like a drag-and-drop from the Finder (as a Smart Object if set in the Photoshop > Preferences > General > Place or Drag Raster Images as Smart Objects, not if set otherwise) and works across files, too.
I don’t think I had noticed that previously, but that behaviour may well be fully intentional. -
Disabling close 'X' icon in the title bar of JDialog
I found that JDialogs by default come up with the close 'X' icon. The only manipulation that can be done is by setting the DefaultCloseOperation.
Is there some way I can avoid showing that icon on the title bar?
My JDialog already has a 'Close' button and I have written an action listener for it. I dont want to listen to WindowEvents as well.JDialog d = new JDialog((Frame)c, true);
d.setSize(400,300);
d.setUndecorated(true);
d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);That bit of code seems to get rid of the title bar entirely and cause a MetalLookAndFeel dragging bar without an X to appear.
Let me know if this is a satisfying solution
My full test code followsimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DyalogTest extends JFrame
public DyalogTest()
super("Dialog Test");
setSize(500, 400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JButton b = new JButton("Initiate Dialog");
b.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
Component c = SwingUtilities.getRoot((Component)e.getSource());
JDialog d = new JDialog((Frame)c, true);
d.setUndecorated(true);
d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
JButton b = new JButton("Dispose");
b.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
Component c = SwingUtilities.getRoot((Component)e.getSource());
JDialog d = (JDialog)c;
d.setVisible(false);
d.dispose();
d.getContentPane().setLayout(new FlowLayout());
JPanel p = new JPanel();
p.setPreferredSize(new Dimension(400,300));
p.setBorder(BorderFactory.createTitledBorder("Vanilla Dialog"));
p.add(b);
d.setContentPane(p);
d.pack();
d.setVisible(true);
c.add(b);
public static void main(String[] args)
new DyalogTest().setVisible(true);
} -
Displaying an icon in the title bar of a web page
Hi Friends,
Pls temme how 2 display a given icon in the title bar of a web - page, i mean in the title bar of the web - browser which loads the page.
Thanks in advance,
Kottayam AchayanHi Friends,
Pls temme how 2 display a given icon in the title bar
of a web - page, i mean in the title bar of the web -
browser which loads the page.
Thanks in advance,
Kottayam AchayanIn web.xml, you can use the <icon> element to specify the image to be used.
<icon>
<small-icon><!-- Specify a 16X16 GIF or JPG --></small-icon>
<large-icon><!-- Specify a 32X32 GIF or JPG --></large-icon>
</icon>Hope this helps.
Annie. -
Changing the icon in the title bar
How can I go about changing the Icon in the title bar that goes next to the title?
setIconImage(Image image) for JFrame.
setFrameIcon(Icon icon) for JInternalFrame.
Take a look at the API. -
Setting an icon in the title bar of a JFrame...
Hi,
how do I set an image (icon) in the title bar of a JFrame (in the top left corner)?
In JInternalFrame there is a method
public void setFrameIcon(Icon icon)to set an image in the title bar of this internal frame - but in a JFrame I didn't find any method like this...
Thanks in advance
- StephanThanks ICE, that works for me...
this.setIconImage(new ImageIcon("img\\foo.jpg").getImage());- Stephan -
Volume icon in the Title Bar of my Treo 800w?!
I don't know completely how to explain this, but here it goes:
I have a Palm Treo 800w for Sprint. Yesterday, I looked at my phone (that I've had for 3-4 months now) and noticed a symbol that I've never seen in Title Bar on the right-hand side. It was an icon for volume, except it provided more(and simpler) options for volume. When you click on it, it showed the volume levels you could choose, but you could also select On, Off, or Vibrate. I went to look at the icons provided in the User Guide, but it wasn't any of them. ALSO, this icon in the Title Bar replaced where my battery icon usually would go.
Anyways, my phone died, and when I turned it back on, it resumed to normal and didn't show the icon anymore. I like that icon, so I looked all around on my phone and read the user guides, but found NOTHING! Please help me if you can!
Megan
Post relates to: Treo 800w (Sprint)Sometimes after you use the media player (and under other equally unpredictable circumstances) the volume/speaker icon replaces the battery icon. I don't think I've ever clicked it, so I don't know whether it's functions are duplicative of an equally convenient icon.
Since most people are much more concerned about their battery life, every post I have seen here on this was a complaint about the change rather than a request for it.
Anyway, I don't think there is any built-in way for users to change the icons on that bar. There might be third party software or registry edits to do it; that would require more research. -
Displaying our own icon at the title bar of a frame.
Hai,
How do i display an Icon of my choice at the title bar of a frame or a dialog box.
Thank you.Thank you shahidjava for the kind reply,
I tried your code as follows but I'am getting an exception saying "wrong number of arguments in the method.".
Can you please help this out.
import java.awt.*;
import java.awt.event.*;
public class testIcon extends Frame
public testIcon()
setVisible(true);
setTitle("mohammad afzal....!");
setBounds(100,100,200,200);
getIconImage("afzal.gif");
public static void main(String args[])
testIcon ti=new testIcon();
} -
How add a new icon in the title bar?
does anyone know how to change the default "java icon" that appears on the title bar of a Window (in an application Frame)?
Hi,
use the method public void setIconImage(Image) in Frame (inherited by JFrame).
best regards -
Set an icon in the title bar.
Hello,
i am unable to set an icon before the title in the title bar.
i am using jdk1.4.
could someone plz tell me how to do this.
i have tried the setFrameIcon method...but it only works for internal frames...not for JFrame.
By default it is the tea cup and saucer icon( well, that is what it is right?)...how can i replace this with my own icon?Try this,
Toolkit kit = Toolkit.getDefaultToolkit();
Image icon = kit.getImage("myicon.gif");
setIconImage(icon); -
Clicking on enclosing folder's icon in the title bar doesn't open Finder
I create PDF booklet from Mellel document using PDF service. Preview application opens newly created PDF document. I Command+click on its icon in the document window's title bar, move cursor one level lower and click on the encompassing folder's ("temp") icon. I expect new Finder's window to open and show me PDF document selected. However, Finder doesn't open. Disk permissions repaired. One week old clean Leopard installation. When I click on the icon in the TextEdit window's title bar and do the same, encompassing Finder's folder opens in a new window. Word also opens Finder window. ONly Preview doesn't work. It used to work at least one month ago. Where the problem could be?
Please post the solution so it will help others, and mark this topic as "solved" so it is easier to track the status when browsing the forum.
-
Setting icon in JDialog title bar.
Hi all,
Can u send me the code for setting the icon in the title bar of JDialog?
Currently i'm working on linux.
Is there any possible way to set it.1) Swing related questions should be posted in the Swing forum.
2) Quit multi posting, you where given the answer yesterday when you originally posted this question.
Maybe you are looking for
-
In my current environemnt Production database has one physical standby database. The size of the database is 5 TB. Due the network failure 4 days archivelog files were not copied to primary database (archivelog files were deleted in primary database)
-
When I type my ID to log in to my gmail account, Firefox provides me with all the previous IDs that I have ever used. Some of them are wrong or should not be revealed. I want to disable this feature of Firefox. I know it's Firefox that does this, as
-
May be to complex for project 2010
Hello, My company recently purchased Microsoft project 2010 to track current jobs. We are becoming a large land surveying company with very large contracts. Each job could last a year or more and have about 12 task during that duration. Between each
-
TS4147 How to remove all the duplicated contacts from ICloud?
How to remove all the duplicated contacts from ICloud?
-
Flash Player Crash status update
Hi, I created a bug a while ago on https://bugs.adobe.com/jira/browse/FP-5553 for a repeatable flash crash issue with the current flash player. Unfortunately, I got locked out of being able to view the bug as it might be a security bug. I'm keen to