List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
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 w w . j a v a 2 s . c om jopDialog.setVisible(true); Object userSelection = jop.getValue(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;/*from w w w .j a va2s . c om*/ JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); label = new JLabel("Raw Number:"); input = new JFormattedTextField(2424.50); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Object elements[][] = { { new Font("Courier", Font.BOLD, 16), Color.YELLOW, "This" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, "Computer" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer);//from w w w. java2s. c o m JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;//from w ww. j a v a2 s . co m JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); label = new JLabel("Raw Number:"); input = new JFormattedTextField(2424.50); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.add(new JTextField()); frame.pack(); frame.setVisible(true); }
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);/* ww w . j a va2 s . com*/ g2.drawString("\u032e\u0624\u0639", 40, 80); } }; f.setSize(200, 200); f.setVisible(true); }
From source file:JColorChooserSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JColorChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel("www.java2s.com", JLabel.CENTER); label.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); frame.add(label, BorderLayout.SOUTH); final JColorChooser colorChooser = new JColorChooser(label.getBackground()); colorChooser.setBorder(BorderFactory.createTitledBorder("Pick Foreground Color")); frame.add(colorChooser, BorderLayout.CENTER); frame.pack();// w w w.j av a 2 s . c o m frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { final JColorChooser colorChooser = new JColorChooser(); final JLabel previewLabel = new JLabel("I Love Swing", JLabel.CENTER); previewLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); previewLabel.setSize(previewLabel.getPreferredSize()); previewLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); colorChooser.setPreviewPanel(previewLabel); ActionListener okActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("OK Button"); System.out.println(colorChooser.getColor()); }//www .j av a 2s .c om }; ActionListener cancelActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Cancel Button"); } }; final JDialog dialog = JColorChooser.createDialog(null, "Change Button Background", true, colorChooser, okActionListener, cancelActionListener); dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("JLabel Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 12)); label.setForeground(Color.GRAY); frame.add(label);//from w w w .j a v a 2 s . c o m frame.pack(); frame.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);//from w ww . ja va 2s.c o m f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:ChangingTitleBorderDirection.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border lineBorder = new LineBorder(Color.RED, 5); Font font = new Font("Serif", Font.ITALIC, 12); Border titledBorder = new TitledBorder(lineBorder, "Hello", TitledBorder.LEFT, TitledBorder.BELOW_BOTTOM, font, Color.RED);// w w w . java 2 s. c o m JLabel aLabel = new JLabel("Bevel"); aLabel.setBorder(titledBorder); aLabel.setHorizontalAlignment(JLabel.CENTER); frame.add(aLabel); frame.setSize(400, 200); frame.setVisible(true); }