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 / General / January 2006

Tip: Looking for answers? Try searching our database.

JOption Dialog and color...

Thread view: 
sanna - 24 Jan 2006 19:56 GMT
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-)



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



©2009 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.