List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.blue); JFrame frame = new JFrame(); frame.add(label);/* w w w. jav a 2s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.add(new JComponent() { public void paintComponent(Graphics g) { // Some parameters. String text = "Some Label"; int centerX = 150, centerY = 100; int ovalWidth = 200, ovalHeight = 100; // Draw oval g.setColor(Color.BLUE); g.fillOval(centerX - ovalWidth / 2, centerY - ovalHeight / 2, ovalWidth, ovalHeight); // Draw centered text FontMetrics fm = g.getFontMetrics(); double textWidth = fm.getStringBounds(text, g).getWidth(); g.setColor(Color.WHITE); g.drawString(text, (int) (centerX - textWidth / 2), (int) (centerY + fm.getMaxAscent() / 2)); }/*from ww w . j a v a2s. co m*/ }); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.GRAY); JFrame frame = new JFrame(); frame.add(label);/*from w w w . j a v a 2 s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.BLUE); JFrame frame = new JFrame(); frame.add(label);/*w w w .ja v a 2 s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.black); JFrame frame = new JFrame(); frame.add(label);// w w w . j a va 2s . c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.WHITE); JFrame frame = new JFrame(); frame.add(label);/*from w w w .j av a2s .co m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.white); JFrame frame = new JFrame(); frame.add(label);// ww w . j a v a 2s .c om frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.green); JFrame frame = new JFrame(); frame.add(label);/*w w w . jav a2 s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.BLACK); JFrame frame = new JFrame(); frame.add(label);//from w ww . ja v a 2 s. c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.GREEN); JFrame frame = new JFrame(); frame.add(label);/*from ww w.j ava 2 s . c om*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }