List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
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 a va 2 s. c o m*/ comboBox.setUI(new MyUI()); }
From source file:Main.java
public Main() { super("Main"); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); contentPane.add(new JButton("OK")); contentPane.add(new JButton("Cancel")); applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT); }
From source file:MainClass.java
public MainClass() { super("MainClass"); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); contentPane.add(new JButton("OK")); contentPane.add(new JButton("Cancel")); applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT); }
From source file:Main.java
Main() { JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(280, 300);/* w ww . jav a 2 s. com*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); scrollBarVertical.setPreferredSize(new Dimension(20, 200)); scrollbarHorizontal.setPreferredSize(new Dimension(200, 20)); scrollbarHorizontal.setValue(50); scrollBarVertical.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (scrollBarVertical.getValueIsAdjusting()) return; System.out.println("Value of vertical scroll bar: " + ae.getValue()); } }); scrollbarHorizontal.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { System.out.println("Value of horizontal scroll bar: " + ae.getValue()); } }); f.add(scrollBarVertical); f.add(scrollbarHorizontal); f.setVisible(true); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("Use JList"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(200, 160);// w ww . j a v a 2s . c o m jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jlst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jlst.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent le) { int idx = jlst.getSelectedIndex(); if (idx != -1) System.out.println("Current selection: " + languages[idx]); else System.out.println("Please choose a language."); } }); jfrm.add(new JScrollPane(jlst)); jfrm.setSize(300, 300); jfrm.setVisible(true); }
From source file:MainClass.java
public MainClass() { super("Opaque JPanel Demo"); setSize(400, 200);// w ww . j a v a2 s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel opaque = createNested(true); JPanel notOpaque = createNested(false); getContentPane().setLayout(new FlowLayout()); getContentPane().add(opaque); getContentPane().add(notOpaque); }
From source file:Test.java
public Test() { this.setBounds(100, 100, 200, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setType(Type.UTILITY); this.setLayout(new FlowLayout()); JButton exitButton = new JButton("Exit"); this.add(exitButton); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0);//from w w w . ja v a2 s. com } }); }
From source file:FlowLayout1.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); for (int i = 0; i < 20; i++) cp.add(new JButton("Button " + i)); }
From source file:OpaqueExample.java
public OpaqueExample() { super("Opaque JPanel Demo"); setSize(400, 200);/*from ww w. jav a 2 s . c om*/ setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel opaque = createNested(true); JPanel notOpaque = createNested(false); // Throw it all together getContentPane().setLayout(new FlowLayout()); getContentPane().add(opaque); getContentPane().add(notOpaque); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("Demonstrate a Text Field"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(240, 140);//from w w w . j a va2 s . c o m jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jtf.setActionCommand("TF"); jtf.addActionListener(this); jbtnGetTextUpper.addActionListener(this); jtf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent ce) { System.out.println("Text in real time: " + jtf.getText()); } }); jfrm.add(jtf); jfrm.add(jbtnGetTextUpper); jfrm.setVisible(true); }