• Post Reply Bookmark Topic Watch Topic
  • New Topic

UIManager.setLookAndFeel font size windows7 not working jdk1.7.25 or jdk1.3.0  RSS feed

 
hima reddy
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the below code, font size of the text doesn't change to "new Font("Tahoma", Font.BOLD, 48)". I am running this program in windows 7 OS and jdk 1.7.25.
I even tested with very old jdk version jdk 1.3.0 the behaviour is still the same.
Has any one faced similar issue, Can you please help regarding this?


import java.awt.Component;
import java.awt.Font;

import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;


public class Joption {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

try {

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

} catch (Exception e) {
System.out.println("Exception:"+e);
}
JFrame parentFrame = new JFrame();
showDialogCheckBox(parentFrame, "Message Testing", "Title",
JOptionPane.OK_CANCEL_OPTION,// JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, null, null,
new Font("Tahoma", Font.BOLD, 48),
"Never show this Dialog again!", "", "");

}

public static int showDialogCheckBox(Component parentComponent,
Object message, String title, int optionType, int messageType,
Icon icon, Object[] options, Object initialValue, Font fontMessage,
String checkBoxText, String key, String type) {
UIManager.put("Label.font", fontMessage);

final JCheckBox checkBox = new JCheckBox(checkBoxText);


Object[] msgs = { message, checkBox };
final JOptionPane optionPane = new JOptionPane(msgs, messageType,
optionType, icon, options, initialValue);
final JDialog dialog = optionPane.createDialog(parentComponent, title);

dialog.setVisible(true);

UIManager.put("Label.font", fontMessage);

return 1;
}

}
image.PNG
[Thumbnail for image.PNG]
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- change key CheckBox.font for JCheckBox in UIManager e.g. UIManager.put("CheckBox.font", fontMessage);

- see UIManager Defaults by @camickr
 
hima reddy
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Korbel.

Your suggestion works perfect for checkbox text.

I want only "Message Testing" text to be displayed in bold.
Capture.PNG
[Thumbnail for Capture.PNG]
 
hima reddy
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Text message font is displaying correctly after I change the code to UIManager.put("OptionPane.messageFont", new FontUIResource( "Tahoma", Font.BOLD, 48 ));

Thanks a lot Korbel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!