List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("Full Name :", JLabel.LEFT); label.setFont(new Font("Georgia", Font.PLAIN, 14)); JOptionPane.showMessageDialog(null, label); }
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.PLAIN, 24); }
From source file:Main.java
public static void main(String[] args) { final int w = 20; final int side = 25; final int[][] grid = new int[50][w]; JPanel panel = new JPanel() { public void paintComponent(Graphics g) { Font font = new Font("WingDings", Font.PLAIN, 14); g.setFont(font);/* w w w . jav a 2s . co m*/ int off = 0; for (int i = 0; i < 256 * 256; i++) { if (font.canDisplay((char) i)) { off++; grid[off / w][off % w] = i; int x = off % w * side; int y = (off / w) * side + side; g.drawString("" + (char) i, x, y); } } } }; JFrame frame = new JFrame(); panel.setSize(300, 300); frame.getContentPane().add(panel); frame.setSize(300, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final int columnCount = 10; final int side = 25; final int[][] grid = new int[50][columnCount]; JPanel panel = new JPanel() { public void paintComponent(Graphics g) { Font font = new Font("WingDings", Font.PLAIN, 14); g.setFont(font);//from www . j a v a2s .c o m int off = 0; for (int i = 0; i < 256 * 256; i++) { if (font.canDisplay((char) i) == false) { continue; } off++; grid[off / columnCount][off % columnCount] = i; int x = off % columnCount * side; int y = (off / columnCount) * side + side; g.drawString(Character.toString((char) i), x, y); } } }; JFrame frame = new JFrame(); panel.setSize(300, 300); frame.getContentPane().add(panel); frame.setSize(300, 300); frame.setVisible(true); }
From source file:JOptionPaneDemonstrationLocalized.java
public static void main(String[] argv) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font unicodeFont = new Font("LucidaSans", Font.PLAIN, 12); ResourceBundle bundle = ResourceBundle.getBundle("JOptionPaneResources", Locale.getDefault()); String[] textMessages = new String[3]; textMessages[0] = bundle.getString("Yes"); textMessages[1] = bundle.getString("No"); textMessages[2] = bundle.getString("Cancel"); JOptionPane jop = new JOptionPane(bundle.getString("MessageText"), JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, textMessages); JDialog jopDialog = jop.createDialog(null, bundle.getString("TitleText")); jop.setFont(unicodeFont);/*from w ww . java2s . c om*/ jopDialog.setVisible(true); Object userSelection = jop.getValue(); }
From source file:UnicodeText.java
public static void main(String[] args) { JFrame f = new JFrame() { public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Lucida Sans Regular", Font.PLAIN, 32); g2.setFont(font);//from w w w . j a v a 2 s . co m g2.drawString("\u032e\u0624\u0639", 40, 80); } }; f.setSize(200, 200); f.setVisible(true); }
From source file:MyLabel.java
public static void main(String[] args) { String lyrics = "<html>Line<br>line<br>line</html>"; JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(10, 10)); JLabel label = new JLabel(lyrics); label.setFont(new Font("Georgia", Font.PLAIN, 14)); label.setForeground(new Color(50, 50, 25)); panel.add(label, BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JFrame f = new JFrame(); f.add(panel);/* w w w .j a va 2 s . co m*/ f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); String s = "The quick brown fox jumps over the lazy dog!"; Font font = new Font(Font.SERIF, Font.PLAIN, 24); JLabel l1 = new MyLabel(s); l1.setFont(font);//w w w .j a v a 2 s . co m f.setContentPane(l1); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { String text = "java2s.com"; BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = img.createGraphics(); Font font = new Font("Arial", Font.PLAIN, 48); g2d.setFont(font);// w w w.ja v a 2 s .com FontMetrics fm = g2d.getFontMetrics(); int width = fm.stringWidth(text); int height = fm.getHeight(); g2d.dispose(); img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); g2d = img.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g2d.setFont(font); fm = g2d.getFontMetrics(); g2d.setColor(Color.BLACK); g2d.drawString(text, 0, fm.getAscent()); g2d.dispose(); ImageIO.write(img, "png", new File("Text.png")); }
From source file:Main.java
public static void main(String[] args) { JFrame window = new JFrame("Example"); JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); JComboBox comboBoxfields = new JComboBox(COMBO_BOX_ELEMENTS); comboBoxfields.setFont(new Font("sansserif", Font.TRUETYPE_FONT | Font.PLAIN, 15)); comboBoxfields.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); comboBoxfields.setMaximumRowCount(5); comboBoxfields.addActionListener(//w w w. j a v a 2 s . co m e -> System.out.println("'" + comboBoxfields.getSelectedItem().toString() + "'" + " was selected")); contentPane.add(comboBoxfields); window.add(contentPane); window.setSize(500, 500); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); }