Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2004

Tip: Looking for answers? Try searching our database.

System Menu Icon Question

Thread view: 
beachnut - 29 Apr 2004 16:16 GMT
Hi, all.

What's the easiest way to override a "heavyweight"
dialog's system menu icon, so I can show an icon
of choice, rather than the default one (Sun's Java)?

Thanks!
bn
Andrew Thompson - 29 Apr 2004 16:31 GMT
> What's the easiest way to override a "heavyweight"
> dialog's system menu icon, so I can show an icon
> of choice, rather than the default one (Sun's Java)?

Give the parent frame an icon, e.g.
<http://www.physci.org/jvmclean.jsp?pt=download>

The Dialog will inheret that icon, instead
of the default.

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Steve W. Jackson - 29 Apr 2004 16:42 GMT
>:Hi, all.
>:
[quoted text clipped - 4 lines]
>:Thanks!
>:bn

By heavyweight, you mean AWT?  No matter, the answer is the same for
Swing, AFAIK.  You can't set the icon on a dialog unless you decorate it
yourself (in Swing -- don't know about AWT equivalents).  In order to
have an input to the icon it uses, you need to set the icon on its
owning Frame/JFrame.  In Swing, there's a complaint about the dialog not
showing its icon if it's not resizable (or maybe if it is -- I forget
just at the moment).  But it otherwise inherits the frame icon specified
in the owning JFrame specified when it was created.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

Thomas Fritsch - 29 Apr 2004 17:00 GMT
>Hi, all.
>
[quoted text clipped - 5 lines]
>bn
>  

Hi,

A Dialog shows the same system menu icon as its parent Frame.
Hence,  to change the dialog's icon you have to change the frame's icon.
I think the easiest way to achieve this, is with the help of an
ImageIcon and a resource file packaged in your jar.
For example:

ImageIcon icon = new ImageIcon(yourFrame.getClass().getResource("yourIcon.gif"));
yourFrame.setIconImage(icon.getImage());

Thomas

______________________________________
Thomas<dot>Fritsch<squiggle>ops<dot>de
Fred L. Kleinschmidt - 29 Apr 2004 23:23 GMT
> Hi, all.
>
[quoted text clipped - 4 lines]
> Thanks!
> bn

As others have said, use
 yourFrame.setIconImage(image);
However, be sure you do this *before* the Frame is made visible. This
will work for a JFrame as well as a Frame, but not for a JInternalFrame.

For a JInternalFrame, you have to use:
 yourJInternalFrame.setFrameIcon( imageIcon );
and it must be done *after* the JInternalFrame is made visible.

Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.