List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
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()); }//www . ja v a2s .c o m }); cp.add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("Check Box Demo"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(300, 200);//from ww w. j a va 2 s . c om jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jcbOption1.setEnabled(false); jcbOption2.setEnabled(false); jcbOption3.setEnabled(false); jcbControl.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (jcbControl.isSelected()) { jcbOption1.setEnabled(true); jcbOption2.setEnabled(true); jcbOption3.setEnabled(true); System.out.println("enabled."); } else { jcbOption1.setEnabled(false); jcbOption2.setEnabled(false); jcbOption3.setEnabled(false); System.out.println("disabled."); } } }); jcbOption1.addItemListener(this); jcbOption2.addItemListener(this); jcbOption3.addItemListener(this); jfrm.add(jcbControl); jfrm.add(jcbOption1); jfrm.add(jcbOption2); jfrm.add(jcbOption3); jfrm.setVisible(true); }
From source file:Button1.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(b1); cp.add(b2); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300, 200);//from w w w . j a v a 2 s . c o m blocker = new JDialog(this, true); blocker.setLayout(new FlowLayout()); blocker.add(new JLabel("I'm blocking EDT!")); JProgressBar progress = new JProgressBar(); progress.setIndeterminate(true); blocker.add(progress); blocker.pack(); timer = new Timer(3000, new ActionListener() { public void actionPerformed(ActionEvent e) { doSomeWork(); } }); timer.setRepeats(false); timer.start(); }
From source file:Main.java
private Main() { combobox.setEditable(true);/*ww w . ja v a 2 s . c o m*/ JTextField editor = (JTextField) combobox.getEditor().getEditorComponent(); editor.addKeyListener(this); setLayout(new FlowLayout()); add(combobox); pack(); setVisible(true); }
From source file:RevalidateExample.java
public RevalidateExample() { super("Revalidation Demo"); setSize(300, 150);//from ww w . ja v a 2s . 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() { JFrame jfrm = new JFrame("Cut, Copy, and Paste"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(230, 150);/* w w w .j a v a 2s . com*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnCut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.cut(); update(); } }); jbtnPaste.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.paste(); update(); } }); jbtnCopy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent le) { jtf.copy(); update(); } }); jtf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent ce) { update(); } }); jfrm.add(jtf); jfrm.add(jbtnCut); jfrm.add(jbtnPaste); jfrm.add(jbtnCopy); jfrm.setVisible(true); }
From source file:Main.java
public Main() { JPanel borderLayoutPanel = new JPanel(new BorderLayout()); borderLayoutPanel.setBorder(BorderFactory.createTitledBorder("BorderLayout Panel")); borderLayoutPanel.add(createGridPanel(), BorderLayout.CENTER); JPanel flowLayoutPanel = new JPanel(new FlowLayout()); flowLayoutPanel.setBorder(BorderFactory.createTitledBorder("FlowLayout Panel")); flowLayoutPanel.add(createGridPanel()); setBorder(BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP)); setLayout(new GridLayout(1, 0, GAP, 0)); add(borderLayoutPanel);/*w w w .j a v a 2 s .co m*/ add(flowLayoutPanel); }
From source file:Main.java
public Test() { setSize(500, 210);/*from w w w.j av a 2s .co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable tabell = new JTable(cells, name); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JScrollPane(tabell), BorderLayout.CENTER); }
From source file:Test.java
public Test() { this.setBounds(100, 100, 200, 100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createRaisedSoftBevelBorder()); this.setLayout(new FlowLayout()); JButton exitButton = new JButton("Exit"); panel.add(exitButton);/* w w w . j av a2s .c om*/ this.add(panel); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); }