
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;


/** DemoAbsolute - program to demonstrate absolute positioning
* of components.<p>
*
* @see <a href="DemoAbsolute.java">source code</a>
* @author Scott MacKenzie, 2002
* @author William Soukoreff, 2012
*/
public class DemoAbsolute extends JFrame
{
   public static void main(String[] args)
   {
      // use look and feel for my system (Win32)
      try {
         UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {}

      DemoAbsolute frame = new DemoAbsolute();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setTitle("DemoAbsolute");
      frame.pack();
      frame.setVisible(true);
   }


   private JButton b1;
   private JButton b2;
   private JButton b3;
   private JButton b4;
   private JButton b5;

   public DemoAbsolute()
   {
      // ----------------------------------
      // construct and configure components
      // ----------------------------------

      b1 = new JButton("Carrot");
      b2 = new JButton("Yam");
      b3 = new JButton("Broccoli");
      b4 = new JButton("Brussel Sprouts");
      b5 = new JButton("Zucchini");

      // -----------------
      // layout components
      // -----------------

      JPanel panel = new JPanel();
      panel.setLayout(null);
      panel.add(b1);
      panel.add(b2);
      panel.add(b3);
      panel.add(b4);
      panel.add(b5);
      panel.setPreferredSize(new Dimension(250, 200)); // need this!

      // specify components' position (x/y) and size (width/height)
      b1.setBounds(10, 10, 70, 30);
      b2.setBounds(40, 150, 70, 40);
      b3.setBounds(50, 50, 80, 30);
      b4.setBounds(15, 90, 150, 30);
      b5.setBounds(150, 40, 80, 25);

      // make panel this JFrame's content pane

      setContentPane(panel);
   }
}
