List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setSize(300, 200);/*from w w w.ja v a 2 s .com*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("java2s.com"); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("java2s.com"); label.setEnabled(false);/* w ww . j a va 2 s . c om*/ f.add(label); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String[] selections = { "green", "red", "orange", "dark blue" }; JList list = new JList(selections); list.setSelectedIndex(1);/*w w w. j a va 2 s . co m*/ System.out.println(list.getSelectedValue()); frame.add(new JScrollPane(list)); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setVisible(true);//from ww w .jav a2 s. c o m JButton button1 = new JButton(""); JButton button2 = new JButton(""); frame.getContentPane().add(button1); frame.getContentPane().add(button2); button1.addActionListener(e -> { System.out.println("Lambda"); }); button2.addActionListener(Main::doSomething); }
From source file:Main.java
public static void main(String[] args) { final JFrame parent = new JFrame("Parent Frame"); parent.setLayout(new FlowLayout()); parent.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); parent.setBounds(100, 100, 300, 200); parent.setVisible(true);// www .j a va 2s .com JDialog dialog1 = new JDialog(parent, "Dialog1 - Modeless Dialog"); dialog1.setBounds(200, 200, 300, 200); dialog1.setVisible(true); JDialog dialog2 = new JDialog(parent, "Dialog2 - Document-Modal Dialog", Dialog.ModalityType.DOCUMENT_MODAL); dialog2.setBounds(300, 300, 300, 200); JDialog dialog3 = new JDialog(dialog2, "Dialog3 - Modeless Dialog"); dialog3.setBounds(400, 400, 300, 200); dialog3.setVisible(true); dialog2.setVisible(true); }
From source file:JComboBoxTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("JComboBox Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String[] selections = { "green", "red", "orange", "dark blue" }; JComboBox comboBox = new JComboBox(selections); comboBox.setSelectedIndex(1);/*from w w w . j a v a 2 s.c o m*/ System.out.println(comboBox.getSelectedItem()); frame.add(comboBox); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String text = "A JTextArea object represents a multiline area for displaying text. " + "You can change the number of lines that can be displayed at a time, " + "as well as the number of columns. You can wrap lines and words too. " + "You can also put your JTextArea in a JScrollPane to make it scrollable."; JTextArea textAreal = new JTextArea(text, 5, 10); textAreal.setPreferredSize(new Dimension(100, 100)); JTextArea textArea2 = new JTextArea(text, 5, 10); textArea2.setPreferredSize(new Dimension(100, 100)); JScrollPane scrollPane = new JScrollPane(textArea2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); textAreal.setLineWrap(true);/* ww w .java 2 s . c om*/ textArea2.setLineWrap(true); frame.add(textAreal); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String[] selections = { "green", "red", "orange", "dark blue" }; JList list = new JList(selections) { // This method is called as the cursor moves within the list. public String getToolTipText(MouseEvent evt) { // Get item index int index = locationToIndex(evt.getPoint()); // Get item Object item = getModel().getElementAt(index); // Return the tool tip text return "tool tip for " + item; }//from w ww .jav a 2 s. c o m }; list.setSelectedIndex(1); System.out.println(list.getSelectedValue()); frame.add(new JScrollPane(list)); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String s[]) { JWindow win = new JWindow(); JPanel pan = new JPanel(); win.add(pan, "Center"); pan.setLayout(new FlowLayout()); pan.add(new JButton("Hello")); win.setSize(200, 200);/*from ww w .j av a 2 s.c o m*/ win.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setSize(200, 360);//from w w w . j av a 2s . c o m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("A default label"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); f.add(label); f.setVisible(true); }