List of usage examples for java.awt Container setLayout
public void setLayout(LayoutManager mgr)
From source file:GridSizeTest.java
public GridSizeTest() { Container pane = getContentPane(); pane.setLayout(new GridLayout(2, 2)); JButton button = new JButton("First"); pane.add(button);//from w w w . ja v a 2 s. co m button = new JButton("Second with a very long name"); pane.add(button); button = new JButton("Hi"); button.setFont(new Font("Courier", Font.PLAIN, 36)); pane.add(button); button = new JButton("There"); pane.add(button); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField field1 = new JTextField("Life's a drag", 20); JTextField field2 = new JTextField("and then you drop", 20); field1.setDragEnabled(true);//from w w w. ja va 2 s.c o m field2.setDragEnabled(true); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(field1); content.add(field2); pack(); }
From source file:DragDropText.java
public DragDropText() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField field1 = new JTextField("Life's a drag", 20); JTextField field2 = new JTextField("and then you drop", 20); field1.setDragEnabled(true);/* ww w. j a va2 s . c om*/ field2.setDragEnabled(true); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(field1); content.add(field2); pack(); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);//w w w . ja va 2 s . co m setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); }
From source file:MainClass.java
public MainClass() { super("Month Spinner"); setSize(200, 100);/*from w w w . j ava 2 s .c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); }
From source file:Main.java
public Main() { setSize(200, 100);/*from www .ja va2s.c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); // Start the spinner today, but don't set a min or max date // The increment should be a month JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); }
From source file:Main.java
Main() { JFrame f1 = new JFrame("Selection"); Container f = new Container(); f.setLayout(new FlowLayout()); String s[] = { "Red", "Green", "Yellow", "Black" }; c = new JComboBox(s); JPanel p = new JPanel(); c.addItemListener(this); f1.add(p);/* www . j a v a 2 s . co m*/ p.add(c); f1.setSize(500, 500); f1.setVisible(true); }
From source file:Main.java
Main() { String[] items = { "Item1", "Item2" }; comboBox = new JComboBox<>(items); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(comboBox);/* ww w. j av a2 s.c om*/ comboBox.setUI(new MyUI()); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);//from w w w.java 2 s .com setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); System.out.println(s.getNextValue()); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);//from w w w . jav a 2 s .c om setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); System.out.println(s.getPreviousValue()); }