List of usage examples for javax.swing.text StyledEditorKit.FontSizeAction StyledEditorKit.FontSizeAction
public FontSizeAction(String nm, int size)
From source file:components.TextComponentDemo.java
protected JMenu createStyleMenu() { JMenu menu = new JMenu("Style"); Action action = new StyledEditorKit.BoldAction(); action.putValue(Action.NAME, "Bold"); menu.add(action);/*from w ww . ja v a2s. co m*/ action = new StyledEditorKit.ItalicAction(); action.putValue(Action.NAME, "Italic"); menu.add(action); action = new StyledEditorKit.UnderlineAction(); action.putValue(Action.NAME, "Underline"); menu.add(action); menu.addSeparator(); menu.add(new StyledEditorKit.FontSizeAction("12", 12)); menu.add(new StyledEditorKit.FontSizeAction("14", 14)); menu.add(new StyledEditorKit.FontSizeAction("18", 18)); menu.addSeparator(); menu.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif")); menu.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif")); menu.addSeparator(); menu.add(new StyledEditorKit.ForegroundAction("Red", Color.red)); menu.add(new StyledEditorKit.ForegroundAction("Green", Color.green)); menu.add(new StyledEditorKit.ForegroundAction("Blue", Color.blue)); menu.add(new StyledEditorKit.ForegroundAction("Black", Color.black)); return menu; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * Sets the font family and size//ww w .j a va2 s . com * @param family the family name * @param size the size */ public void setFontFamilyAndSize(String family, int size) { // Family ActionEvent evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, family); Action action = new StyledEditorKit.FontFamilyAction(family, family); action.actionPerformed(evt); // Size evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, Integer.toString(size)); action = new StyledEditorKit.FontSizeAction(Integer.toString(size), size); action.actionPerformed(evt); }