List of usage examples for javax.swing JFrame setLayout
public void setLayout(LayoutManager manager)
LayoutManager
. From source file:Main.java
License:asdf
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 a v a 2 s.c om*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("asdf"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); label.setPreferredSize(new Dimension(150, 100)); 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.setSize(200, 360);/*from w ww. j a v a 2 s.co m*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel( "<html>Use HTML to create<br>" + "a multiline message." + "<br>One<br>Two<br>Three"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JCheckBox a = new JCheckBox("A"); a.setSelected(true);//from www . j av a 2 s .c o m JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Car Features")); frame.add(a); frame.add(b); frame.add(c); frame.add(d); frame.pack(); frame.setVisible(true); }
From source file:JListTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("JList Test"); 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 ww .j a v a 2 s . c o m System.out.println(list.getSelectedValue()); frame.add(new JScrollPane(list)); frame.pack(); frame.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);//w ww. ja va 2 s . c om 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.setVisible(true);//w w w. ja v a 2 s . co 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) { JRadioButton button1 = new JRadioButton("Red"); JRadioButton button2 = new JRadioButton("Green"); JRadioButton button3 = new JRadioButton("Blue"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(button1);//from ww w . ja v a 2 s . c om colorButtonGroup.add(button2); colorButtonGroup.add(button3); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Color:")); frame.add(button1); frame.add(button2); frame.add(button3); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JCheckBox a = new JCheckBox("A"); a.setSelected(true);//from w w w .ja va 2 s. c o m a.setMnemonic(KeyEvent.VK_A); JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Car Features")); frame.add(a); frame.add(b); frame.add(c); frame.add(d); frame.pack(); frame.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(300, 200);//from www .j a v a2 s .c o m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("java2s.com"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); label.setPreferredSize(new Dimension(150, 100)); label.setText("Centered"); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JRadioButton button1 = new JRadioButton("Red"); JRadioButton button2 = new JRadioButton("Green"); JRadioButton button3 = new JRadioButton("Blue"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(button1);// w w w .j a v a 2 s.c o m colorButtonGroup.add(button2); colorButtonGroup.add(button3); button1.setSelected(true); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Color:")); frame.add(button1); frame.add(button2); frame.add(button3); frame.pack(); frame.setVisible(true); }