Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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

 
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am going to test your electrical conductivity with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic