Example usage for java.awt GridLayout GridLayout

List of usage examples for java.awt GridLayout GridLayout

Introduction

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

Prototype

public GridLayout(int rows, int cols, int hgap, int vgap) 

Source Link

Document

Creates a grid layout with the specified number of rows and columns.

Usage

From source file:TitledExample.java

public TitledExample() {
    super(true);/* w  w w  .  jav  a2s . c om*/

    this.setLayout(new GridLayout(1, 1, 5, 5));

    JLabel label = new JLabel("Titled Border");
    label.setHorizontalAlignment(JLabel.CENTER);

    TitledBorder titled = new TitledBorder("Title");
    label.setBorder(titled);

    add(label);
}

From source file:Main.java

private JPanel getPanel() {
    JPanel panel = new JPanel(new GridLayout(0, 1, 5, 5));
    JLabel nameLabel = getLabel("Your Name : java2s.com");
    JLabel ageLabel = getLabel("Your Age : 12");
    JLabel yearLabel = getLabel("Your Birth Year : 2004");
    panel.add(nameLabel);//from ww  w. j av  a2s .c  o  m
    panel.add(ageLabel);
    panel.add(yearLabel);

    return panel;
}

From source file:MatteExample.java

public MatteExample() {
    super(true);//from ww w.  j  a v a2 s.  c  o  m
    this.setLayout(new GridLayout(1, 2, 5, 5));

    JLabel label1 = new JLabel("Matte Border");
    JLabel label2 = new JLabel("Matte Border (Icon)");

    label1.setHorizontalAlignment(JLabel.CENTER);
    label2.setHorizontalAlignment(JLabel.CENTER);

    Icon icon = new ImageIcon("yourFile.gif");
    MatteBorder matte = new MatteBorder(35, 35, 35, 35, Color.blue);
    MatteBorder matteicon = new MatteBorder(35, 35, 35, 35, icon);
    label1.setBorder(matte);
    label2.setBorder(matteicon);

    add(label1);
    add(label2);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createMatteBorder(2, 5, 2, 5, Color.BLUE));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/* w ww .  ja  va 2  s.c o m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
    simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JLabel simpleLabel = new JLabel("SIMPLE BORDERS", JLabel.CENTER);
    simplePanel.add(simpleLabel);//w ww  .  j ava  2s. c  o m

    add(simplePanel);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createTitledBorder("Title Border"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);//ww w . j av a2  s  .c  o  m
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    JLabel etchedLowBorderLabel = new JLabel("Lowered Etched Border", JLabel.CENTER);
    etchedLowBorderLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    simplePanel.add(etchedLowBorderLabel);

    add(simplePanel);//from   www.ja v a2  s.  c  om
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(1, 1, 5, 5));

    JLabel etchedRasBorderLabel = new JLabel("Raised Etched Border", JLabel.CENTER);
    etchedRasBorderLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    simplePanel.add(etchedRasBorderLabel);

    add(simplePanel);/*from w ww  .j  a v  a 2 s .  c o m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel("TITLE BORDERS", JLabel.CENTER);
    titleLabel.setForeground(Color.red.darker());

    add(simplePanel);//  w w w. j  av  a 2s.  com
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    JLabel bevelLowBorderLabel = new JLabel("Lowered Bevel Border", JLabel.CENTER);
    bevelLowBorderLabel.setBorder(BorderFactory.createLoweredBevelBorder());
    simplePanel.add(bevelLowBorderLabel);

    add(simplePanel);/*from w  ww  . j  a  v  a2s .co m*/
}