Hi,
In a part of my program I am openeing an error warnign as following:
if (myVal != yourVal) {
JOptionPane.showMessageDialog(null,"WARNING: \n MyVal does NOT
yourVal.","Error Dialog",JOptionPane.ERROR_MESSAGE);
}
But I need that message "WARNING: \n MyVal does NOT yourVal" printed
out in red color. and currently its printing in black. Any suggestions?
Thanks,
ecoswiss
Vova Reznik - 24 Jan 2006 20:09 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> But I need that message "WARNING: \n MyVal does NOT yourVal" printed
> out in red color. and currently its printing in black. Any suggestions?
Use HTML.
"<HTML><FONT color=\"red\">WARNING:<BR>MyVal does NOT yourVal</FONT></HTML>"
> Thanks,
>
> ecoswiss
Oliver Wong - 24 Jan 2006 20:11 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> But I need that message "WARNING: \n MyVal does NOT yourVal" printed
> out in red color. and currently its printing in black. Any suggestions?
Parts of Swing allow you to use HTML. I haven't tried it with
JOptionPane, but I suppose it's worth a shot.
<code>
JOptionPane.showMessageDialog(null,"<font color='#FF0000'>WARNING: \n MyVal
does NOT yourVal.</font>","Error Dialog",JOptionPane.ERROR_MESSAGE);
</code>
Alternatively, you could manually create a dialog, and put in a JLabel
set to whatever color you want. See
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JDialog.html#JDialog()
- Oliver
Vova Reznik - 24 Jan 2006 20:17 GMT
>>Hi,
>>
[quoted text clipped - 23 lines]
>
> - Oliver
Or :)
UIManager.put("OptionPane.messageForeground", Color.RED);
After using that you'd better set Color back to its original.
Or ...
sanna - 24 Jan 2006 20:50 GMT
> Or :)
> UIManager.put("OptionPane.messageForeground", Color.RED);
> After using that you'd better set Color back to its original.
>
> Or ...
Using
UIManager.put("OptionPane.messageForeground", java.awt.Color.red);
I get message: Cannot resolve symbol
symbol: variable UIManager
Do I need to defien it somewhere?
Using html chanegs the color but font size and style is totally
changed from other dialog messages......
Which looks a bit funny....
any suggestions?
Thanks a lot!
Vova Reznik - 24 Jan 2006 21:11 GMT
>>Or :)
>>UIManager.put("OptionPane.messageForeground", Color.RED);
[quoted text clipped - 15 lines]
>
> Thanks a lot!
You'd better to use HTML, but
javax.swing.UIManager
IchBin - 24 Jan 2006 21:15 GMT
>> Or :)
>> UIManager.put("OptionPane.messageForeground", Color.RED);
[quoted text clipped - 15 lines]
>
> Thanks a lot!
You need this import
import javax.swing.UIManager;

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)