Article View: borland.public.jbuilder.java.swing
Article #10257Change JOptionPane Font & Color
From: BC
Date: Wed, 20 Oct 1999 00:00
Date: Wed, 20 Oct 1999 00:00
32 lines
1795 bytes
1795 bytes
I'd like to change the font and background color of my JDialog in a
JOptionPane. It does not work. Please review my code and see what I am
missing. Or is there another way to do this. Thanks!
--- code snippet (start) ---.
/** Just to create a modal dialog that displays a informative message in
bold-faced font with an OK button **/
JOptionPane optionPane = new JOptionPane(myMesg,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.CLOSED_OPTION, myIcon);
JDialog dialog = new JDialog(this, "Test", true);
dialog.getContentPane().setBackground(Color.lightGray);
dialog.getContentPane().setFont(new java.awt.Font("SansSerif", 1, 12));
// optionPane.setBackground(Color.lightGray); ** note: I also try
this; but it doesn't work.
// optionPane.setFont(new java.awt.Font("SansSerif", 1, 12));
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
dialog.setVisible(false);
}
});
dialog.setContentPane(optionPane);
dialog.pack();
dialog.setLocationRelativeTo(myFrame);
dialog.setVisible(true);
--- (end) ---
Technical Details
Message-ID:
<380DAD16.D87DFEFC@aol.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,4971284f8be13142,start X-Google-Attributes: gid111d45,public X-Google-Thread: 10a146,4971284f8be13142,start X-Google-Attributes: gid10a146,public X-Google-Thread: 10fd6d,4971284f8be13142,start X-Google-Attributes: gid10fd6d,public From: BC <Bameco@aol.com> Subject: Change JOptionPane Font & Color Date: 1999/10/20 Message-ID: <380DAD16.D87DFEFC@aol.com> X-Deja-AN: 538382942 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing,comp.lang.java.gui,comp.lang.java.programmer