Example usage for java.awt FlowLayout FlowLayout

List of usage examples for java.awt FlowLayout FlowLayout

Introduction

In this page you can find the example usage for java.awt FlowLayout FlowLayout.

Prototype

public FlowLayout() 

Source Link

Document

Constructs a new FlowLayout with a centered alignment and a default 5-unit horizontal and vertical gap.

Usage

From source file:Main.java

public MyPanel() throws Exception {
    setLayout(new FlowLayout());
    int size = 100;

    URL url = new URL("http://www.java2s.com/style/download.png");
    BufferedImage bi = ImageIO.read(url);

    Image left = createImage(size, Color.YELLOW);

    Image merged = merge(left, bi);

    add(new JLabel(new ImageIcon(merged)));
}

From source file:kuvalataaja.user_interface.GUI.java

public GUI() {
    textPanel = new JPanel(new BorderLayout());
    buttonPanel = new JPanel(new FlowLayout());
    textArea = createJLabel();//  w ww. j  a va  2  s. c  om
    runButton = new JButton("Run");
    tutButton = new JButton("Tutorial");
    //testButton = new JButton("Test");
    textPanel.add(textArea);
    buttonPanel.add(tutButton);
    buttonPanel.add(runButton);
    //buttonPanel.add(testButton);
    this.getContentPane().add(textPanel, BorderLayout.NORTH);
    this.getContentPane().add(buttonPanel);
    this.init();
}

From source file:Buttons.java

public void init() {
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(jb);//from   w w w.  j av  a2 s  .  com
    cp.add(new JToggleButton("JToggleButton"));
    cp.add(new JCheckBox("JCheckBox"));
    cp.add(new JRadioButton("JRadioButton"));
    JPanel jp = new JPanel();
    jp.setBorder(new TitledBorder("Directions"));
    jp.add(up);
    jp.add(down);
    jp.add(left);
    jp.add(right);
    cp.add(jp);
}

From source file:MainClass.java

private void makeGUI() {
    setLayout(new FlowLayout());

    ImageIcon france = new ImageIcon("france.gif");
    JButton jb = new JButton(france);
    jb.setActionCommand("France");
    jb.addActionListener(this);
    add(jb);//from  w  w w  .j  av a 2s .c  om

    ImageIcon germany = new ImageIcon("germany.gif");
    jb = new JButton(germany);
    jb.setActionCommand("Germany");
    jb.addActionListener(this);
    add(jb);

    ImageIcon italy = new ImageIcon("italy.gif");
    jb = new JButton(italy);
    jb.setActionCommand("Italy");
    jb.addActionListener(this);
    add(jb);

    ImageIcon japan = new ImageIcon("japan.gif");
    jb = new JButton(japan);
    jb.setActionCommand("Japan");
    jb.addActionListener(this);
    add(jb);

    jtf = new JTextField(15);
    add(jtf);
}

From source file:Test.java

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, Color.lightGray, Color.yellow));
    //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.RAISED, 
    //  Color.lightGray, Color.yellow));
    //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, 
    //  Color.lightGray, Color.lightGray, Color.white, Color.orange));

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);/*  w w w .j a  v  a 2s. c  o m*/
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}

From source file:HTMLButton.java

public void init() {
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getContentPane().add(new JLabel("<html>" + "<i><font size=+4>Kapow!"));
            // Force a re-layout to include the new label:
            validate();/*w w w.  j ava 2  s.  c om*/
        }
    });
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(b);
}

From source file:LookAndFeel.java

public LookAndFeel() {
    super("Look And Feel");
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    for (int i = 0; i < samples.length; i++)
        cp.add(samples[i]);/* ww  w  . jav  a  2 s  . c  o  m*/
}

From source file:Composite.java

public void init() {
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(alphaLabel);//from w  w w .  j a va 2s  . c o m
    getContentPane().add(rulesLabel);

    alphas.addItem("1.0");
    alphas.addItem("0.75");
    alphas.addItem("0.50");
    alphas.addItem("0.25");
    alphas.addItem("0.0");
    alphas.addItemListener(this);
    getContentPane().add(alphas);

    rules.addItem("SRC");
    rules.addItem("DST_IN");
    rules.addItem("DST_OUT");
    rules.addItem("DST_OVER");
    rules.addItem("SRC_IN");
    rules.addItem("SRC_OVER");
    rules.addItem("SRC_OUT");
    rules.addItem("CLEAR");
    rules.addItemListener(this);
    getContentPane().add(rules);

    comp = new CompPanel();
    getContentPane().add(comp);

    validate();
}

From source file:Button2.java

public void init() {
    b1.addActionListener(bl);//w w w  . j  ava  2  s . c  o  m
    b2.addActionListener(bl);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(b1);
    cp.add(b2);
    cp.add(txt);
}

From source file:ComplexExample.java

public ComplexExample() {
    JPanel left = new JPanel();
    left.setBackground(Color.red);

    JPanel right = new JPanel();
    right.setBackground(Color.white);

    new MyDropTargetListener(right);

    DragSource ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(left, DnDConstants.ACTION_COPY, this);

    setLayout(new FlowLayout());
    add(left);/*from w  ww  . ja v a2s .c  o  m*/
    add(right);

    setSize(40, 50);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);
}