?
Solved

Set font for InternalMessageDialog

Posted on 2011-02-14
6
Medium Priority
?
312 Views
Last Modified: 2012-06-27
I am using InternalMessageDialog in my application.How can i set font for the same.

I am pasting the code below-

javax.swing.JOptionPane.showInternalMessageDialog(this.getParent(),"Please Enter City","Information Message",javax.swing.JOptionPane.INFORMATION_MESSAGE);
               
0
Comment
Question by:Aurii
  • 2
  • 2
  • 2
6 Comments
 
LVL 26

Accepted Solution

by:
ksivananth earned 1000 total points
ID: 34894454
try this,

JLabel l1 = new JLabel("Please Enter City"),
   l1.setFont( new Font(font, Font.PLAIN, 16) );
JPanel p = new JPanel();
   p.add(l1);
javax.swing.JOptionPane.showInternalMessageDialog(this.getParent(), p,"Information Message",javax.swing.JOptionPane.INFORMATION_MESSAGE);


0
 

Author Comment

by:Aurii
ID: 34894551
It works for msg ..but how to change the font of  the "OK"  button now ..
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34894790
This code changes
the font of the button

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.*;

public class ConfigOptionPaneLanguage {
  public static void main(final String[] args) {
//
  
    Font font = new Font("Dialog", Font.BOLD,20);
    UIManager.put("OptionPane.buttonFont", font);   

    JFrame parent = new JFrame();


    String multiLineMsg[] = { "Hello,", "World"} ;
    JOptionPane.showMessageDialog(parent, multiLineMsg);
  }
}

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Aurii
ID: 34895947
Sorry, but I am not getting this code. How to apply it in my code?
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 34896064
that changes the font for all option pane instance you open in your app, not sure if thats what you want!

if not, better create your own dialog!
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34899051
Perhaps you can set it when you create some Option panes
and then set it to another font at another time
if you post your piece of code, pmaybe we could figure out how
to use it in your particular situation.
I ran this particular program and saw that it works.

Now I ran the code below and it first showed me pane
with big font and then showed me next option pane
with smalle font

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.*;

public class ConfigOptionPaneLanguage {
  public static void main(final String[] args) {
//
  
    Font font = new Font("Dialog", Font.BOLD,20);
   Font font1 = new Font("Dialog", Font.BOLD,12);
    UIManager.put("OptionPane.buttonFont", font);   

    JFrame parent = new JFrame();


    String multiLineMsg[] = { "Hello,", "World"} ;
    JOptionPane.showMessageDialog(parent, multiLineMsg);

       UIManager.put("OptionPane.buttonFont", font1);
        JOptionPane.showMessageDialog(parent, multiLineMsg);



  }
}

Open in new window


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question