List of usage examples for java.awt Font deriveFont
public Font deriveFont(Map<? extends Attribute, ?> attributes)
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.BOLD); }
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(24F); }
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(AffineTransform.getRotateInstance(0.5)); }
From source file:DrivedFont.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Pick to Change Background"); Font myFont = new Font("Serif", Font.ITALIC | Font.BOLD, 12); Font newFont = myFont.deriveFont(50F); button.setFont(newFont);//from w w w .j a v a 2 s . c om f.add(button, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { File f = new File("your.ttf"); FileInputStream in = new FileInputStream(f); Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, in); Font dynamicFont32Pt = dynamicFont.deriveFont(32f); JLabel testLabel = new JLabel(dynamicFont.getName()); testLabel.setFont(dynamicFont32Pt);/* w w w . j a va2 s. co m*/ JFrame frame = new JFrame("Font Loading Demo"); frame.getContentPane().add(testLabel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { File f = new File("your.ttf"); FileInputStream in = new FileInputStream(f); Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, in); Font dynamicFont32Pt = dynamicFont.deriveFont(32f); JLabel testLabel = new JLabel("Dynamically loaded font \"" + dynamicFont.getName() + "\""); testLabel.setFont(dynamicFont32Pt);/*from www. ja v a2 s .c om*/ JFrame frame = new JFrame("Font Loading Demo"); frame.getContentPane().add(testLabel); frame.pack(); frame.setVisible(true); }
From source file:ws.moor.bt.grapher.Grapher.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("Please specify a tab-separated values file"); System.exit(1);/*w w w.ja va 2s . com*/ } File file = new File(args[0]); final CSVMapCollector collector = new CSVMapCollector( new CSVSkipFilter(new CSVInputStream(new FileInputStream(file)), 0 * 1000)); JFrame window = new JFrame("Grapher"); window.setSize(1100, 800); window.setLayout(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(null); List<String> possibleNames = collector.getAvailableStreams(); Collections.sort(possibleNames); TreeNode root = convertToTree(possibleNames); final JTree tree = new JTree(root); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { List<String> names = new ArrayList<String>(); final TreePath[] paths = tree.getSelectionModel().getSelectionPaths(); if (paths == null) { chartPanel.setChart(null); return; } for (TreePath path : paths) { Object lastPath = path.getLastPathComponent(); if (lastPath instanceof DefaultMutableTreeNode) { Object value = ((DefaultMutableTreeNode) lastPath).getUserObject(); if (value instanceof NodeValue) { names.add(value.toString()); } } } chartPanel.setChart(createChart(collector, names.toArray(new String[names.size()]))); } }); Font font = tree.getFont(); tree.setFont(font.deriveFont(10.0f)); JScrollPane scrollPane = new JScrollPane(tree); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(scrollPane); splitPane.setRightComponent(chartPanel); splitPane.setDividerLocation(200); window.setContentPane(splitPane); window.setVisible(true); }
From source file:Main.java
public static Font boldFont(Font baseFont) { return baseFont.deriveFont(Font.BOLD); }
From source file:Main.java
/** * Change a component's Font size./*w w w . jav a 2 s .c om*/ * <p> * The Font family and Font style are preserved in the updated Font. * @param component The component to change the Font presentation of. * @param size The new size of Font. * @return The new Font installed to the component. */ public static Font changeFontSize(Component component, float size) { Font existingFont = component.getFont(); Font newFont = existingFont.deriveFont(size); component.setFont(newFont); return newFont; }
From source file:Main.java
/** * Apply bold font to a Jlabel./*from ww w .ja va 2s . c o m*/ * @param label */ public static void bold(final JLabel label) { final Font font = label.getFont(); label.setFont(font.deriveFont(font.getStyle() ^ Font.BOLD)); }