List of usage examples for java.awt Container setLayout
public void setLayout(LayoutManager mgr)
From source file:Main.java
Main() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); ArrayList data = new ArrayList(); data.add("Hi"); data.add("Hello"); data.add("Goodbye"); list = new JList(data.toArray()); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) return; System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); }//from w ww .java2 s . c o m }); cp.add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);// 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(); SpinnerDateModel model = new SpinnerDateModel(today, null, null, Calendar.MONTH); JSpinner s = new JSpinner(); s.setModel(model); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); }
From source file:CombinedLayoutManager.java
public CombinedLayoutManager() { Container pane = getContentPane(); pane.setLayout(new BorderLayout()); pane.add(getHeader(), BorderLayout.NORTH); pane.add(getTextArea(), BorderLayout.CENTER); pane.add(getButtonPanel(), BorderLayout.SOUTH); }
From source file:HTMLButton.java
public void init() { b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().add(new JLabel("<html>" + "<i><font size=+4>Kapow!")); // Force a re-layout to include the new label: validate();/*w w w .j a va2 s .co m*/ } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(b); }
From source file:MainClass.java
MainClass() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); ArrayList data = new ArrayList(); data.add("Hi"); data.add("Hello"); data.add("Goodbye"); list = new JList(data.toArray()); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) return; System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); }//ww w . ja v a2 s .c o m }); cp.add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/*from w ww.ja v a 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); try { s.commitEdit(); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Button2.java
public void init() { b1.addActionListener(bl);/*w w w .j a va2 s . c o m*/ b2.addActionListener(bl); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(b1); cp.add(b2); cp.add(txt); }
From source file:RevalidateExample.java
public RevalidateExample() { super("Revalidation Demo"); setSize(300, 150);/*from w w w. j a va2 s .c om*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Font font = new Font("Dialog", Font.PLAIN, 10); final JButton b = new JButton("Add"); b.setFont(font); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(b); b.addActionListener(new ActionListener() { // Increase the size of the button's font each time it's clicked int size = 20; public void actionPerformed(ActionEvent ev) { b.setFont(new Font("Dialog", Font.PLAIN, ++size)); b.revalidate(); // invalidates the button & validates its root pane } }); }
From source file:MonthSpinner.java
public MonthSpinner() { super("Month Spinner"); setSize(200, 100);/*from w ww . ja v a 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(); // 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:Buttons.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(jb);/*from w ww. ja va2 s . c om*/ cp.add(new JToggleButton("JToggleButton")); cp.add(new JCheckBox("JCheckBox")); cp.add(new JRadioButton("JRadioButton")); JPanel jp = new JPanel(); jp.setBorder(new TitledBorder("Directions")); jp.add(up); jp.add(down); jp.add(left); jp.add(right); cp.add(jp); }