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