List of usage examples for javax.swing JFrame add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.setSize(100, 100);//from w w w . jav a 2s . c om frame.setVisible(true); }
From source file:Hypnosis1.java
public static void main(String[] args) { JFrame f = new JFrame("Hypnosis"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Hypnosis1(4)); f.setSize(300, 300);/*from w w w . j a va 2 s . c o m*/ f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { Locale locale = Locale.getDefault(); ResourceBundle rb = ResourceBundle.getBundle("MyResources", locale); JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("I18N Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 2)); frame.add(new JLabel(rb.getString("userName"))); frame.add(new JTextField()); frame.add(new JLabel(rb.getString("password"))); frame.add(new JPasswordField()); frame.add(new JButton(rb.getString("login"))); frame.pack();//from www . j a v a 2s. c o m frame.setVisible(true); }
From source file:TwoButtons.java
public static void main(String[] args) { JFrame f = new JFrame(); JPanel basic = new JPanel(); basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS)); f.add(basic); basic.add(Box.createVerticalGlue()); JPanel bottom = new JPanel(); bottom.setAlignmentX(1f);//from ww w .ja va2 s. c om bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS)); JButton ok = new JButton("OK"); JButton close = new JButton("Close"); bottom.add(ok); bottom.add(Box.createRigidArea(new Dimension(5, 0))); bottom.add(close); bottom.add(Box.createRigidArea(new Dimension(15, 0))); basic.add(bottom); basic.add(Box.createRigidArea(new Dimension(0, 15))); f.setSize(300, 250); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextField tf = new JTextField("mm"); tf.setPreferredSize(tf.getPreferredSize()); tf.setText(""); JPanel pHacked = new JPanel(); pHacked.add(tf);//from w w w.jav a2 s .c o m JPanel pStock = new JPanel(); pStock.add(new JTextField(2)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new java.awt.GridLayout(0, 1)); frame.add(pHacked); frame.add(pStock); frame.setSize(150, 150); frame.setVisible(true); tf.requestFocus(); }
From source file:FontShow.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(420, 300);/*from w ww . j a va2s.c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new FontShow()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override// w w w. ja va2 s .c o m public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new BackgroundPane()); frame.pack(); frame.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.pack();/*w w w . ja v a 2 s. c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); int treeSelectedRows[] = { 3, 1 }; tree.setSelectionRows(treeSelectedRows); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override/*from ww w .j a va 2 s .c o m*/ public void valueChanged(TreeSelectionEvent treeSelectionEvent) { JTree treeSource = (JTree) treeSelectionEvent.getSource(); System.out.println("Min: " + treeSource.getMinSelectionRow()); System.out.println("Max: " + treeSource.getMaxSelectionRow()); System.out.println("Lead: " + treeSource.getLeadSelectionRow()); System.out.println("Row: " + treeSource.getSelectionRows()[0]); } }; tree.addTreeSelectionListener(treeSelectionListener); JFrame frame = new JFrame("JTree With Multi-Discontiguous selection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setPreferredSize(new Dimension(380, 320)); frame.setLocation(150, 150); frame.pack(); frame.setVisible(true); }
From source file:GridLayoutTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("GridLayout Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 2)); frame.add(new JButton("Button 1")); frame.add(new JButton("Button 2")); frame.add(new JButton("Button 3")); frame.add(new JButton("Button 4")); frame.add(new JButton("Button 5")); frame.add(new JButton("Button 6")); frame.add(new JButton("Button 7")); frame.add(new JButton("Button 8")); frame.pack();//from w w w .j a v a 2 s . com frame.setVisible(true); }