List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:Main.java
public static Font createBoldFont(Font font) { if (font == null) { throw new NullPointerException("font == null"); }//from w ww. j av a 2 s. com String fontName = font.getName(); int fontSize = font.getSize(); return new Font(fontName, Font.BOLD, fontSize); }
From source file:Main.java
public static void SetJTableAlignment(javax.swing.JTable jTable, ComponentOrientation componentOrientation) { Font tahoma = new Font("Tahoma", Font.PLAIN, 11); int labelAlighnment = JLabel.RIGHT; int headerAlighnment = JLabel.RIGHT; if (componentOrientation == ComponentOrientation.LEFT_TO_RIGHT) { labelAlighnment = JLabel.LEFT; headerAlighnment = JLabel.LEFT; }// w w w. j a v a 2s.co m DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer(); defaultTableCellRenderer.setHorizontalAlignment(labelAlighnment); // defaultTableCellRenderer.setFont(tahoma); for (int columnIndex = 0; columnIndex < jTable.getColumnCount(); columnIndex++) { if (jTable.getModel().getColumnClass(columnIndex).equals(Boolean.class)) { jTable.getColumnModel().getColumn(columnIndex).setWidth(60); jTable.getColumnModel().getColumn(columnIndex).setMaxWidth(90); jTable.getColumnModel().getColumn(columnIndex).setMinWidth(10); jTable.getColumnModel().getColumn(columnIndex).setPreferredWidth(60); continue; } if (jTable.getModel().getColumnClass(columnIndex).equals(ImageIcon.class)) { continue; } jTable.getColumnModel().getColumn(columnIndex).setCellRenderer(defaultTableCellRenderer); } DefaultTableCellRenderer renderer; renderer = (DefaultTableCellRenderer) jTable.getTableHeader().getDefaultRenderer(); renderer.setHorizontalAlignment(headerAlighnment); jTable.getTableHeader().setDefaultRenderer(renderer); }
From source file:Main.java
/** Convenience method for {@link #setUIFont(Font)} */ public static void setUIFont(String name, int style, int size) { final Font f = new Font(name, style, size); setUIFont(f);/* w w w .j a va2 s.com*/ }
From source file:Main.java
/** * Creates a new <code>JTextField</code> object with the given properties. * * @param bounds The position and dimension attributes * @return A <code>JTextField</code> object */// w w w .j a v a 2 s . c o m public static JTextField createJTextField(Rectangle bounds) { JTextField txtField = new JTextField(); txtField.setFont(new Font("Times New Roman", Font.PLAIN, 12)); txtField.setBounds(bounds); return txtField; }
From source file:Main.java
public static Font getFontProperty(Element properties, String name) { String[] font = getPropertyNode(properties, name).getAttributes().getNamedItem(FONT_ATTR).getNodeValue() .split(","); return new Font(font[0], new Integer(font[1]), new Integer(font[2])); }
From source file:Main.java
private static void setFontStyle(Component c, int fontStyle) { Font newLabelFont = new Font(c.getFont().getName(), fontStyle, c.getFont().getSize()); c.setFont(newLabelFont);/*from ww w .j a v a2 s. c om*/ }
From source file:Main.java
public static Font getFont() { return new Font("Arial", Font.PLAIN, 10); }
From source file:DataCharts.PieGraph.java
public static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("Data Unavailable"); plot.setCircular(false);/* www .j a va2 s.c om*/ plot.setLabelGap(0.01); plot.setBackgroundPaint(null); chart.setBorderPaint(null); chart.setBackgroundPaint(null); return chart; }
From source file:Main.java
/** * Creates a new <code>JTextPane</code> object with the given properties. * * @param text The text which will appear in the text pane * @param backgroundColor The background color * @return A <code>JTextPane</code> object *//* w w w . ja v a2 s . c om*/ public static JTextPane createJTextPane(String text, Color backgroundColor) { JTextPane jTextPane = new JTextPane(); jTextPane.setBorder(null); jTextPane.setEditable(false); jTextPane.setBackground(backgroundColor); jTextPane.setFont(new Font("Times New Roman", Font.PLAIN, 14)); if (text != null) { jTextPane.setText(text); } jTextPane.setVerifyInputWhenFocusTarget(false); jTextPane.setAutoscrolls(false); return jTextPane; }
From source file:Main.java
/** * Displays a message dialog with given information. *//* w w w . j a va 2 s. co m*/ public static void showInformationDialog(Component component, String message) { final JPanel panel = new JPanel(new BorderLayout(5, 5)); final JLabel messageLabel = new JLabel(message); messageLabel.setFont(new Font("Dialog", Font.BOLD, messageLabel.getFont().getSize())); panel.add(messageLabel, BorderLayout.CENTER); // Adjust stack trace dimensions final Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); screenDimension.setSize(screenDimension.getWidth() * 0.7, screenDimension.getHeight() * 0.7); final Dimension maxStackTraceDimension = new Dimension(500, 500); maxStackTraceDimension.setSize(Math.min(maxStackTraceDimension.getWidth(), screenDimension.getWidth()), Math.min(maxStackTraceDimension.getHeight(), screenDimension.getHeight())); JOptionPane.showMessageDialog(component, panel, "Information", JOptionPane.INFORMATION_MESSAGE); }