List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String... args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel contentPane = new JPanel(); contentPane.setOpaque(true);// w w w .j a v a2 s .c o m contentPane.setBackground(Color.WHITE); contentPane.setLayout(null); JLabel label = new JLabel("This JPanel uses Absolute Positioning", JLabel.CENTER); label.setSize(300, 30); label.setLocation(5, 5); JButton button = new JButton("USELESS"); button.setSize(100, 30); button.setLocation(95, 45); contentPane.add(label); contentPane.add(button); frame.setContentPane(contentPane); frame.setSize(310, 125); frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.RED); JFrame frame = new JFrame(); frame.add(label);/* ww w .ja 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.red); JFrame frame = new JFrame(); frame.add(label);/*from www. j a va2 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) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override/* ww w. jav a 2 s.co m*/ protected void paintComponent(Graphics g) { super.paintComponent(g); int y = 0; for (int size = 4; size <= 24; size += 2) { g.setFont(new Font("Arial", Font.BOLD, size)); g.drawString("Name", 0, y); int heightOfFont = g.getFontMetrics().getHeight(); y += heightOfFont; } } @Override public Dimension getPreferredSize() { return new Dimension(300, 300); } }; frame.add(panel); frame.setLocationByPlatform(true); frame.setVisible(true); frame.pack(); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.PINK); JFrame frame = new JFrame(); frame.add(label);/*from w w w . j a va 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.CYAN); JFrame frame = new JFrame(); frame.add(label);/*from ww 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.pink); JFrame frame = new JFrame(); frame.add(label);/*from w w w . j a va2s . 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.cyan); JFrame frame = new JFrame(); frame.add(label);//from ww w . jav a 2 s. com 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.gray); JFrame frame = new JFrame(); frame.add(label);//w ww . 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:RelativeXY.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1;//from w w w . j av a 2 s . com gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(500, 300); f.setVisible(true); }