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); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); JPanel a = new JPanel(); a.setAlignmentX(Component.CENTER_ALIGNMENT); a.setPreferredSize(new Dimension(100, 100)); a.setMaximumSize(new Dimension(100, 100)); // set max = pref a.setBorder(BorderFactory.createTitledBorder("aa")); JPanel b = new JPanel(); b.setAlignmentX(Component.CENTER_ALIGNMENT); b.setPreferredSize(new Dimension(50, 50)); b.setMaximumSize(new Dimension(50, 50)); // set max = pref b.setBorder(BorderFactory.createTitledBorder("bb")); frame.getContentPane().add(a);/* ww w.java2s. c om*/ frame.getContentPane().add(b); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame dialog = new JFrame(); dialog.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); dialog.setResizable(true);/*from w w w .j av a 2 s . c om*/ JPanel guiHolder = new JPanel(); guiHolder.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.PAGE_START; gbc.weightx = 1.0; gbc.weighty = 1.0; guiHolder.add(new JLabel("my test"), gbc); dialog.add(guiHolder); dialog.setSize(new Dimension(320, 240)); dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); System.out.println(jb.getHorizontalTextPosition()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w w w.j a va 2s .c o m*/ f.pack(); f.setVisible(true); }
From source file:GridBagLayoutColumnSpanHORIZONTAL.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.ja v a 2 s. co m gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Third row, spans two columns"), gbc); gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(400, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); JLabel label = new JLabel("User Name:", SwingConstants.RIGHT); JLabel label2 = new JLabel("Password:", SwingConstants.RIGHT); JTextField userNameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(); frame.add(label);/*from w ww.j av a 2 s. c o m*/ frame.add(userNameField); frame.add(label2); frame.add(passwordField); frame.setSize(200, 70); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); System.out.println(jb.getDisabledIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);//www . j a v a 2s.co m f.pack(); f.setVisible(true); }
From source file:MultiClickThreshholdDemo.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AbstractButton bn = new JButton(); bn.setMultiClickThreshhold(1000);/*from www .ja va 2 s. co m*/ bn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action"); } }); frame.add(bn); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Table Title", TitledBorder.CENTER, TitledBorder.TOP)); JTable table = new JTable(3, 3); panel.add(new JScrollPane(table)); frame.add(panel);//from w ww . j ava 2 s . c o m frame.pack(); frame.setVisible(true); }