List of usage examples for java.awt Container setLayout
public void setLayout(LayoutManager mgr)
From source file:Main.java
public Main() { super("JSpinner Icon Test"); setSize(300, 80);/*from w w w .j a va 2s. c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"), new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") }; JSpinner s1 = new JSpinner(new SpinnerListModel(nums)); s1.setEditor(new IconEditor(s1)); System.out.println(s1.getEditor()); c.add(new JLabel(" Icon Spinner")); c.add(s1); setVisible(true); }
From source file:ComboBoxes.java
public void init() { for (int i = 0; i < 4; i++) c.addItem(description[count++]); t.setEditable(false);/* www. j av a 2s . com*/ b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (count < description.length) c.addItem(description[count++]); } }); c.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText("index: " + c.getSelectedIndex() + " " + ((JComboBox) e.getSource()).getSelectedItem()); } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); cp.add(c); cp.add(b); }
From source file:Main.java
public Main() { super("JSpinner Icon Test"); setSize(300, 80);// ww w . j a v a 2 s. c o m setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"), new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") }; JSpinner s1 = new JSpinner(new SpinnerListModel(nums)); s1.setEditor(new IconEditor(s1)); c.add(new JLabel(" Icon Spinner")); c.add(s1); setVisible(true); }
From source file:SwingCheckBoxes.java
public void init() { cb1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { trace("1", cb1); }/*w ww. j ava 2s. com*/ }); cb2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { trace("2", cb2); } }); cb3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { trace("3", cb3); } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(new JScrollPane(t)); cp.add(cb1); cp.add(cb2); cp.add(cb3); }
From source file:IconSpinner.java
public IconSpinner() { super("JSpinner Icon Test"); setSize(300, 80);/* w ww . j a va2 s . c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"), new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") }; JSpinner s1 = new JSpinner(new SpinnerListModel(nums)); s1.setEditor(new IconEditor(s1)); c.add(new JLabel(" Icon Spinner")); c.add(s1); setVisible(true); }
From source file:CardLayoutBehaviour.java
public CardLayoutBehaviour() { JPanel tab;/*w w w . j ava 2s . com*/ Container pane = getContentPane(); layout = new CardLayout(); pane.setLayout(layout); tab = new JPanel(); tab.setBackground(Color.red); pane.add(tab, "Red Tab"); tab = new JPanel(); tab.setBackground(Color.green); pane.add(tab, "Green Tab"); tab = new JPanel(); tab.setBackground(Color.blue); pane.add(tab, "Blue Tab"); }
From source file:JListDemo.java
JListDemo(String s) { super(s);/* www. j a v a2 s. com*/ Container cp = getContentPane(); cp.setLayout(new FlowLayout()); ArrayList data = new ArrayList(); data.add("Hi"); data.add("Hello"); data.add("Goodbye"); data.add("Adieu"); data.add("Adios"); 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()); } }); cp.add(list, BorderLayout.CENTER); }
From source file:Popup.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t);//w ww .ja v a 2 s .c o m ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText(((JMenuItem) e.getSource()).getText()); } }; JMenuItem m = new JMenuItem("Hither"); m.addActionListener(al); popup.add(m); m = new JMenuItem("Yon"); m.addActionListener(al); popup.add(m); m = new JMenuItem("Afar"); m.addActionListener(al); popup.add(m); popup.addSeparator(); m = new JMenuItem("Stay Here"); m.addActionListener(al); popup.add(m); PopupListener pl = new PopupListener(); addMouseListener(pl); t.addMouseListener(pl); }
From source file:JTreeSimple.java
/** Construct the object including its GUI */ public JTreeSimple() { super("JTreeSimple"); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); myTree = new JTree(); JScrollPane scroller = new JScrollPane(myTree); cp.add(BorderLayout.CENTER, scroller); cp.add(BorderLayout.SOUTH, quitButton = new JButton("Exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false);//from ww w .j a v a 2s . c o m dispose(); System.exit(0); } }); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); }
From source file:SwingSpinnerTest.java
public SwingSpinnerTest() { super("JSpinner Test"); setSize(300, 180);/*from w ww. ja va 2 s.com*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); c.add(new JLabel(" Basic Spinner")); c.add(new JSpinner()); c.add(new JLabel(" Date Spinner")); c.add(new JSpinner(new SpinnerDateModel())); String weekdays[] = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; c.add(new JLabel(" List Spinner")); c.add(new JSpinner(new SpinnerListModel(weekdays))); c.add(new JLabel(" Number Spinner")); c.add(new JSpinner(new SpinnerNumberModel(0, 0, 100, 5))); c.add(new JLabel(" Rollover List Spinner")); c.add(new JSpinner(new RolloverSpinnerListModel(weekdays))); setVisible(true); }