List of usage examples for javax.swing JFrame setSize
public void setSize(int width, int height)
The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .
From source file:MulticastEvent.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("MulticastTest"); frame.setSize(300, 200); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w .ja va 2 s . co m*/ } }); Container contentPane = frame.getContentPane(); contentPane.add(new MulticastEvent()); frame.show(); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(240, 250); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jscrlpLabel = new JScrollPane( new JLabel("<html>A<br>B<br>C<br>D<br>E<br>F<br>G<br>H<br></html>.")); jscrlpLabel.setPreferredSize(new Dimension(200, 100)); JLabel label = new JLabel("Option"); JCheckBox a = new JCheckBox("A"); JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JCheckBox e = new JCheckBox("E"); Box box = Box.createVerticalBox(); box.add(label);/*from w w w . ja v a 2 s . com*/ box.add(a); box.add(b); box.add(c); box.add(d); box.add(e); JScrollPane jscrlpBox = new JScrollPane(box); jscrlpBox.setPreferredSize(new Dimension(140, 90)); f.add(jscrlpLabel); f.add(jscrlpBox); f.setVisible(true); }
From source file:FontPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("NotHelloWorld2"); frame.setSize(350, 200); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w. java 2 s . co m } }); Container contentPane = frame.getContentPane(); contentPane.add(new FontPanel()); frame.show(); }
From source file:RollingText.java
public static void main(String[] args) { JFrame f = new JFrame("RollingText v1.0"); f.getContentPane().add(new RollingText()); f.setSize(600, 300); f.setVisible(true);//from w ww .j a va2 s . c o m }
From source file:Main.java
public static void main(String args[]) { ImageIcon iconA = new ImageIcon("IconA.gif"); ImageIcon iconDiable = new ImageIcon("disable.gif"); ImageIcon iconOver = new ImageIcon("over.gif"); ImageIcon iconPressed = new ImageIcon("IconAPressed.gif"); final JButton jbtnA = new JButton("Alpha", iconA); JFrame jfrm = new JFrame(); jfrm.setLayout(new FlowLayout()); jfrm.setSize(300, 300); jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnA.setRolloverIcon(iconOver);//from w w w . j a v a 2 s .c om jbtnA.setPressedIcon(iconPressed); jbtnA.setDisabledIcon(iconDiable); jfrm.getRootPane().setDefaultButton(jbtnA); jbtnA.setMnemonic(KeyEvent.VK_A); jbtnA.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { System.out.println("Alpha pressed. Beta is enabled."); jbtnA.setEnabled(!jbtnA.isEnabled()); } }); jfrm.add(jbtnA); jfrm.setVisible(true); }
From source file:Main.java
public static void main(String s[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Main()); f.setSize(220, 220); f.setVisible(true);/*ww w . j a v a 2 s . com*/ }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Main"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(225, 150); frame.setLocation(200, 200);/*from w ww .jav a2 s . c o m*/ frame.setContentPane(new Main()); frame.setVisible(true); }
From source file:GridBag1.java
public static void main(String[] args) { JFrame frame = new JFrame("GridBag1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(225, 150); frame.setLocation(200, 200);/*from ww w .j a va 2s . c o m*/ frame.setContentPane(new GridBag1()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GridBag1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(225, 150); frame.setLocation(200, 200);//from w ww . j av a 2 s . c o m frame.setContentPane(new Main()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(new GridBagLayout()); for (int i = 0; i < 25; i++) { JTextField field = new JTextField("Field " + i, 20); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = i;/*w w w. jav a 2 s . c om*/ panel.add(field, constraints); } JScrollPane scrollPane = new JScrollPane(panel); JButton removeButton = new JButton("Remove Field"); removeButton.addActionListener(e -> { if (panel.getComponentCount() >= 1) { panel.remove(panel.getComponentCount() - 1); scrollPane.revalidate(); scrollPane.repaint(); } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(640, 480); f.setLocation(200, 200); f.getContentPane().add(scrollPane); f.getContentPane().add(removeButton, BorderLayout.SOUTH); f.setVisible(true); }