Jump to content
  • Advertisement
Sign in to follow this  
someboddy

[java] JDialog and icons

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Well, my code is pretty long, so I wrote a shorter test code:

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Well, JInternalFrame is not what I need. Since my code works for you, and my JDK is pretty updated, the problem is probebly on my JVM.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!