List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
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 ww w . j av a2 s.co m*/ 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)); label.setText("Centered"); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); f.add(label); f.setVisible(true); }
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);/* w ww . j av a2s .c o m*/ 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)); label.setText("Top Left"); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.TOP); f.add(label); f.setVisible(true); }
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 ww w.ja v a2 s .co m*/ 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)); label.setText("Bottom Right"); label.setHorizontalAlignment(JLabel.RIGHT); label.setVerticalAlignment(JLabel.BOTTOM); f.add(label); f.setVisible(true); }
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 ww w .j av a 2 s .co m*/ 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)); 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) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("JLabel Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 12)); label.setForeground(Color.GRAY); frame.add(label);/*from w w w . j av a 2 s . c o m*/ frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(240, 250);//from w w w . jav a2 s. co m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jscrlpLabel = new JScrollPane( new JLabel("<html>A<br>B<br>C<br>D<br>E<br>F<br>G<br>H<br></html>.")); jscrlpLabel.setPreferredSize(new Dimension(200, 100)); JLabel label = new JLabel("Option"); JCheckBox a = new JCheckBox("A"); JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JCheckBox e = new JCheckBox("E"); Box box = Box.createVerticalBox(); box.add(label); box.add(a); box.add(b); box.add(c); box.add(d); box.add(e); JScrollPane jscrlpBox = new JScrollPane(box); jscrlpBox.setPreferredSize(new Dimension(140, 90)); f.add(jscrlpLabel); f.add(jscrlpBox); f.setVisible(true); }
From source file:FlowLayoutTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("FlowLayout Test"); 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."; JTextArea textArea1 = new JTextArea(text, 5, 10); textArea1.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); textArea1.setLineWrap(true);//w w w . j a va2 s.c om textArea2.setLineWrap(true); frame.add(textArea1); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("JLabel Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon imageIcon = new ImageIcon("yourFile.gif"); JLabel label = new JLabel("Mixed", imageIcon, SwingConstants.RIGHT); frame.add(label);//from w w w. j av a2 s . co m frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Layout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout()); for (int i = 1; i <= 5; i++) { contentPane.add(new JButton("Button " + i)); }/* ww w .ja v a 2s .c om*/ frame.pack(); frame.setVisible(true); }
From source file:JRadioButtonTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("JRadioButton Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRadioButton button1 = new JRadioButton("Red"); JRadioButton button2 = new JRadioButton("Green"); JRadioButton button3 = new JRadioButton("Blue"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(button1);/*ww w .j av a2 s .c o m*/ colorButtonGroup.add(button2); colorButtonGroup.add(button3); button1.setSelected(true); frame.add(new JLabel("Color:")); frame.add(button1); frame.add(button2); frame.add(button3); frame.pack(); frame.setVisible(true); }