[java] JDialog and icons
How do I set an icon for JDialog? For my JFrames, I have done it using Frame.setIconImage(Image). JDialogs don't have this method, so I thought they will have the same icon as their owner JFrame. However, when I set the icons for my JFrames, the JDialogs still have the JAVA logo as an icon. What can I do to solve this problem?
By the way, the Icons are actualy gif files, but I don't think that's the problem, because they will turn into java.awt.Image objects anyways.
You can change JDialog's Icon using something like
This...
[Edited by - VerMan on June 27, 2005 9:01:35 AM]
This...
[Edited by - VerMan on June 27, 2005 9:01:35 AM]
a quick casual look thu the docs reveals only a setTitle method. mebe hava look at the platform look nd feel classes nd methods ?
hmmm .. furthr search on sun's developer forums yields this. ifn that's still not write perhaps post your query to sun's swing forum yourself?
[Edited by - ops on June 25, 2005 8:06:51 PM]
hmmm .. furthr search on sun's developer forums yields this. ifn that's still not write perhaps post your query to sun's swing forum yourself?
[Edited by - ops on June 25, 2005 8:06:51 PM]
Well, nothing helps, and I keep getting the JAVA logo icon no metter if my JDialog is resizable or not.
I decided I will just use JFrames. Now, does anyone knows how to hide the maximize&minimize buttons so my frames will look like dialogs?
I decided I will just use JFrames. Now, does anyone knows how to hide the maximize&minimize buttons so my frames will look like dialogs?
Please post your code for the JDialog issue... it should have worked using a JFrame with custom icon as a parent.
The only method you can call to hide window-top buttons is setUndecorated(false); It will hide the window's title bar.
Son Of Cain
The only method you can call to hide window-top buttons is setUndecorated(false); It will hide the window's title bar.
Son Of Cain
Well, my code is pretty long, so I wrote a shorter test code:
The dialog still have the coffy cup icon.
By the way, I don't want to hide the border of my JFrames. I just want to hide the minimize and maximize buttons on the title. The title, the close buttons, and the border - I want them visible.
import java.awt.*;import javax.swing.*;public class JDialogTest extends JFrame{ private static Image theIcon; public JDialogTest() { super(""); setSize(100,100); } public static void main(String[] args) { JDialogTest mainFrame=new JDialogTest(); MediaTracker mdtr=new MediaTracker(mainFrame); Image img=Toolkit.getDefaultToolkit().createImage("testicon.GIF"); mdtr.addImage(img,0); try { mdtr.waitForID(0); } catch (InterruptedException e) { System.out.println(e); System.exit(0); } mainFrame.setIconImage(img); mainFrame.setVisible(true); JDialog dialog=new JDialog(mainFrame,"dialog"); dialog.setLocation(150,0); dialog.setSize(50,50); dialog.setVisible(true); }}
The dialog still have the coffy cup icon.
By the way, I don't want to hide the border of my JFrames. I just want to hide the minimize and maximize buttons on the title. The title, the close buttons, and the border - I want them visible.
Yeah, I understood what you wanted, but that is not possible (I never came across it, anyway). The only Component who allows that is the JInternalFrame, when you declare it not closable, and not resizable.
About the JDialog, I copied and pasted your code (changing only the directory and name of the image, of course) and it worked. Are you using an image larger than 32 x 32 pixels? I'm not sure if that is the limit (or even if it exists), but check it out.
Son Of Cain
About the JDialog, I copied and pasted your code (changing only the directory and name of the image, of course) and it worked. Are you using an image larger than 32 x 32 pixels? I'm not sure if that is the limit (or even if it exists), but check it out.
Son Of Cain
Well, I resized my image and I still get the coffy cup icon in the dialog. I guess I should try that JInternalFrame of yours.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement