mercredi 11 mars 2015

Setting JTextField to what is selected in JFontChooser



I found this component recently and its great exactly what I wanted but I am unsure how to use it.


How would I set the font of my JTextField to what is selected by the user in the JFontChooser?


This is all I can find on it:



The JFontChooser class is a swing component for font selection. This class has JFileChooser like APIs. The following code pops up a font chooser dialog.




JFontChooser fontChooser = new JFontChooser();
int result = fontChooser.showDialog(parent);
if (result == JFontChooser.OK_OPTION)
{
Font font = fontChooser.getSelectedFont();
System.out.println("Selected Font : " + font);
}


what I want it to do is:


update: tNumber.setFont(new font(""Tahoma", Font.BOLD, 300));


To what ever the user has chosen for the font style and size in font chooser.




Aucun commentaire:

Enregistrer un commentaire