List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JLabel Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 18)); label.setForeground(Color.RED); frame.add(label);/*w w w.ja va2s . co m*/ frame.pack(); frame.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 ww w . ja v a 2s . com*/ frame.pack(); frame.setVisible(true); }
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: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);/* ww w .j a va 2 s . c o 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 { 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); JFrame frame = new JFrame("Font Loading Demo"); frame.getContentPane().add(testLabel); frame.pack();//w w w. jav a 2 s .c om frame.setVisible(true); }
From source file:FileSamplePanel.java
public static void main(String args[]) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel directoryLabel = new JLabel(" "); directoryLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); frame.add(directoryLabel, BorderLayout.NORTH); final JLabel filenameLabel = new JLabel(" "); filenameLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); frame.add(filenameLabel, BorderLayout.SOUTH); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setControlButtonsAreShown(false); frame.add(fileChooser, BorderLayout.CENTER); frame.pack();//from w w w . j a v a 2s . co m frame.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); f.setContentPane(l1);/* www .j a va 2s .com*/ f.pack(); 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();//from w ww . java 2s.co m frame.setVisible(true); }
From source file:JColorChooserWithCustomPreviewPanel.java
public static void main(String[] a) { 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)); JColorChooser colorChooser = new JColorChooser(); colorChooser.setPreviewPanel(previewLabel); JDialog d = colorChooser.createDialog(null, "", true, colorChooser, null, null); d.setVisible(true);//from w w w . ja v a 2 s .c o m }
From source file:BorderLayoutExample.java
public static void main(String[] args) { BorderSample bs = new BorderSample(); bs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = bs.getContentPane(); pane.setLayout(new BorderLayout()); JLabel label = new JLabel("North", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.NORTH); label = new JLabel("South", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.SOUTH); label = new JLabel("East", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.EAST); label = new JLabel("West", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.WEST); label = new JLabel("Center", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.CENTER); bs.setSize(400, 300);//ww w . j ava2s. c o m bs.setVisible(true); }