List of usage examples for java.awt Container add
public Component add(Component comp)
From source file:RevalidateExample.java
public RevalidateExample() { super("Revalidation Demo"); setSize(300, 150);//from w w w.j a v a2 s . c o m 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:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/*from www . java 2s. 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:QuadCurve.java
public void init() { Container container = getContentPane(); canvas = new DrawingCanvas(); container.add(canvas); }
From source file:Buttons.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(jb); 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);//from w w w. j a v a 2 s.c o m jp.add(down); jp.add(left); jp.add(right); cp.add(jp); }
From source file:MainClass.java
public MainClass() { super("Month Spinner"); setSize(200, 100);/*from ww w . j ava2 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:SimpleMenus.java
public void init() { for (int i = 0; i < items.length; i++) { items[i].addActionListener(al);/*w w w . j ava 2 s . co m*/ menus[i % 3].add(items[i]); } JMenuBar mb = new JMenuBar(); for (int i = 0; i < menus.length; i++) mb.add(menus[i]); setJMenuBar(mb); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); }
From source file:Main.java
public Main() { setSize(200, 100);//from w ww. ja v a 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(); // 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
public Main() { super("Month Spinner"); setSize(200, 100);/*from www.j a v a2 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 . ja v a2 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); System.out.println(s.getPreviousValue()); }
From source file:SwingRadioButtons.java
public void init() { rb1.addActionListener(al);//from w w w .j a v a 2 s . c o m rb2.addActionListener(al); rb3.addActionListener(al); g.add(rb1); g.add(rb2); g.add(rb3); t.setEditable(false); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); cp.add(rb1); cp.add(rb2); cp.add(rb3); }