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 / November 2003

Tip: Looking for answers? Try searching our database.

Newbie, trying to change font on MessageDialog

Thread view: 
Mike - 17 Nov 2003 08:50 GMT
Hi,

I'm pretty new to Java, so forgive me if I'm asking a stupid question.
But I've researched this online, and the only reference I'm finding is
with TextFields and TextAreas.

I'm using a MessageDialog box for a simple "about the program" window,
and I would like to change some of the fonts. Nothing major, just make
the title bigger, etc. How do I do this?

The line I'm using is like this:
JOptionPane.showMessageDialog(null, "Title\n\nAuthor\nDate", "Window
Title", JOptionPane.INFORMATION_MESSAGE);

TIA,

Mike
Andrew Thompson - 17 Nov 2003 08:57 GMT
...
> I'm using a MessageDialog box for a simple "about the program" window,
> and I would like to change some of the fonts. Nothing major, just make
[quoted text clipped - 3 lines]
> JOptionPane.showMessageDialog(null, "Title\n\nAuthor\nDate", "Window
> Title", JOptionPane.INFORMATION_MESSAGE);

JOptionPanes ar great if you do _not_ need to
customize them, and can instead accept one
of the many default configurations offered.
They are tricky to 'tweak' though.

You will probably achieve what you want much
faster using a JDialog.

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
SPG - 17 Nov 2003 17:20 GMT
JOptionPane allows you to pass an Object as the message.
This means you can render JLabels to display your message.

For example:

public void showMessage(String message){
JLabel lblMessage = new JLabel(message);
lblMessage.setFont(new Font("Arial",Font.BOLD,14));
JOptionPane.showMessageDialog(null,new lblMessage,"TEST
TITLE",JOptionPane.INFORMATION_MESSAGE);
}

this will render your message using a bold arial forn sized at 14pts.

HTH

Steve

> Hi,
>
[quoted text clipped - 13 lines]
>
> Mike
Alan Moore - 18 Nov 2003 07:33 GMT
>Hi,
>
[quoted text clipped - 13 lines]
>
>Mike

Use HTML:.  Enclose the message in <html></html> tags, then use <br>,
<font>, etc. to format the message.


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.