List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
From source file:Main.java
public Main() { getContentPane().setLayout(new FlowLayout()); JLabel labelTwo = new JLabel("www.java2s.com"); labelTwo.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.red, Color.black)); add(labelTwo);//from w w w .j ava 2 s . c om JLabel labelThree = new JLabel("MatteBorder"); labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)); add(labelThree); JLabel labelFour = new JLabel("TitledBorder"); labelFour.setBorder( BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM)); add(labelFour); JLabel labelSix = new JLabel("CompoundBorder"); Border one = BorderFactory.createEtchedBorder(); Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue); labelSix.setBorder(BorderFactory.createCompoundBorder(one, two)); add(labelSix); }
From source file:FlowLayoutComponentOrientationRIGHT_TO_LEFT.java
public FlowLayoutComponentOrientationRIGHT_TO_LEFT() { getContentPane().setLayout(new FlowLayout()); getContentPane().add(new JButton("OK")); getContentPane().add(new JButton("Cancel")); applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT); }
From source file:Main.java
public Main(String name) { getContentPane().setLayout(new FlowLayout()); JLabel labelTwo = new JLabel("www.java2s.com"); labelTwo.setBorder(BorderFactory.createEtchedBorder()); add(labelTwo);//www .j a v a 2 s . com JLabel labelThree = new JLabel("MatteBorder"); labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)); add(labelThree); JLabel labelFour = new JLabel("TitledBorder"); labelFour.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(10, 10, 10, 10, MetalIconFactory.getFileChooserHomeFolderIcon()), "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM)); add(labelFour); JLabel labelSix = new JLabel("CompoundBorder"); Border one = BorderFactory.createEtchedBorder(); Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue); labelSix.setBorder(BorderFactory.createCompoundBorder(one, two)); add(labelSix); }
From source file:HtmlLabel.java
public HtmlLabel() { super("HTML Buttons"); setSize(400, 300);/*from w w w . ja v a 2s . c om*/ getContentPane().setLayout(new FlowLayout()); String htmlText = "<html><p><font color=\"#800080\" " + "size=\"4\" face=\"Verdana\">JButton</font> </p>" + "<font size=\"2\"><em>" + "with HTML text</em></font></html>"; JLabel btn = new JLabel(htmlText); getContentPane().add(btn); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Main.java
public Main() { setSize(300, 150);//from w w w . ja v a 2 s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout()); add(b); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { b.setFont(new Font("Dialog", Font.PLAIN, ++size)); b.revalidate(); } }); setVisible(true); }
From source file:ButtonDemo.java
ButtonDemo() { JFrame jfrm = new JFrame("A Button Example"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(220, 90);/*w w w .j av a 2 s . co m*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnA.addActionListener(this); jbtnB.addActionListener(this); jfrm.add(jbtnA); jfrm.add(jbtnB); jfrm.setVisible(true); }
From source file:Main.java
Main() { JFrame f1 = new JFrame("Selection"); Container f = new Container(); f.setLayout(new FlowLayout()); String s[] = { "Red", "Green", "Yellow", "Black" }; c = new JComboBox(s); JPanel p = new JPanel(); c.addItemListener(this); f1.add(p);/*from w ww . j a v a2s . c o m*/ p.add(c); f1.setSize(500, 500); f1.setVisible(true); }
From source file:Main.java
public Main() { setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); table = new Hashtable<Integer, Color>(); table.put(1, Color.RED);//from w ww . jav a 2 s. com table.put(2, Color.BLUE); table.put(3, Color.GREEN); table.put(4, Color.GRAY); c = new JComboBox<String>(); c.addItem("Item 1"); c.addItem("Item 2"); c.addItem("Item 3"); c.addItem("Item 4"); c.addItem("Item 5"); c.addItem("Item 6"); c.addItem("Item 7"); c.addItem("Item 8"); c.setRenderer(new MyListCellRenderer(table)); add(c); setSize(400, 400); setVisible(true); }
From source file:Main.java
Main() { 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()); }//from w w w. jav a2 s. com }); cp.add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:Main.java
public Main() { this.setLayout(new FlowLayout()); this.add(new JButton("test")); this.add(new JCheckBox("test")); this.add(new JRadioButton("test")); this.add(new JProgressBar(0, 100)); JPanel panel = new JPanel() { @Override/*from w ww.ja va 2 s .c o m*/ public Dimension getPreferredSize() { return new Dimension(400, 300); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red); g.fillRect(0, 0, getWidth(), getHeight()); } }; panel.add(new JLabel("Label")); add(panel); setSize(new Dimension(400, 300)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }