List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(getPanel());/* w w w . j ava2s .c om*/ f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Object[][] rowData = {};/*from ww w . ja v a2 s . c o m*/ Object[] columnNames = { "Column 1", "Column 2", "Column 3" }; DefaultTableModel listTableModel; listTableModel = new DefaultTableModel(rowData, columnNames); for (int i = 1; i < 25; i++) { String rowString = "Quiz #" + i; listTableModel.addRow(new Object[] { rowString, "ICON", "ICON" }); } JTable listTable; listTable = new JTable(listTableModel); listTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); listTable.setCellEditor(null); listTable.setBounds(37, 143, 397, 183); JFrame frame = new JFrame(); frame.add(new JScrollPane(listTable)); frame.setVisible(true); frame.pack(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new Main(); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//from w w w . j ava2 s . c o m }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from www.j a v a2 s. co m }); jb.setVerticalAlignment(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Box form = Box.createVerticalBox(); form.add(new JLabel("Name:")); form.add(new JTextField("User Name")); form.add(new JLabel("Birthday:")); JFormattedTextField birthdayField = new JFormattedTextField(new SimpleDateFormat("MM/dd/yy")); birthdayField.setValue(new Date()); form.add(birthdayField);// w ww.j av a2s .co m form.add(new JLabel("Age:")); form.add(new JFormattedTextField(new Integer(32))); form.add(new JLabel("Hairs on Body:")); JFormattedTextField hairsField = new JFormattedTextField(new DecimalFormat("###,###")); hairsField.setValue(new Integer(100000)); form.add(hairsField); form.add(new JLabel("Phone Number:")); JFormattedTextField phoneField = new JFormattedTextField(new MaskFormatter("(###)###-####")); phoneField.setValue("(314)888-1234"); form.add(phoneField); JFrame frame = new JFrame("User Information"); frame.getContentPane().add(form); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from w w w. j a v a2 s . c o m }); jb.setText("new text"); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }// w ww . j a v a 2 s . c o m }); jb.setVerticalTextPosition(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Add the toolbar to a frame JFrame frame = new JFrame(); JToolBar toolbar = new JToolBar(); frame.getContentPane().add(toolbar, BorderLayout.NORTH); frame.pack(); frame.setVisible(true);//from ww w. j a v a2 s .c om }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setSelectedIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w w w .j a v a 2 s . c o m*/ f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w ww . j a v a 2 s . com*/ f.pack(); f.setVisible(true); }