Example usage for java.awt Insets Insets

List of usage examples for java.awt Insets Insets

Introduction

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

Prototype

public Insets(int top, int left, int bottom, int right) 

Source Link

Document

Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

Usage

From source file:Main.java

public Main() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel panel1 = new JPanel();
    Border eBorder = BorderFactory.createEtchedBorder();

    panel1.setBorder(BorderFactory.createTitledBorder(eBorder, "70pct"));
    gbc.gridx = gbc.gridy = 0;//from  w  ww .  ja  va  2 s . c om
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.weightx = gbc.weighty = 70;
    add(panel1, gbc);

    JPanel panel2 = new JPanel();
    panel2.setBorder(BorderFactory.createTitledBorder(eBorder, "30pct"));
    gbc.gridy = 1;
    gbc.weightx = gbc.weighty = 30;
    gbc.insets = new Insets(2, 2, 2, 2);
    add(panel2, gbc);

    JPanel panel3 = new JPanel();
    panel3.setBorder(BorderFactory.createTitledBorder(eBorder, "20pct"));
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 2;
    gbc.weightx = 20;
    gbc.insets = new Insets(2, 2, 2, 2);
    add(panel3, gbc);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setVisible(true);
}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel panel1 = new JPanel();
    Border eBorder = BorderFactory.createEtchedBorder();
    panel1.setBorder(BorderFactory.createTitledBorder(eBorder, "70pct"));
    gbc.gridx = gbc.gridy = 0;//from www . ja  va 2  s  .  co  m
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.weightx = gbc.weighty = 70;
    getContentPane().add(panel1, gbc);
    JPanel panel2 = new JPanel();
    panel2.setBorder(BorderFactory.createTitledBorder(eBorder, "30pct"));
    gbc.gridy = 1;
    gbc.weightx = 30;
    gbc.weighty = 30;
    gbc.insets = new Insets(2, 2, 2, 2);
    getContentPane().add(panel2, gbc);
    pack();
}

From source file:Main.java

public ArrowButton(int direction, int arrowCount, int arrowSize) {
    setMargin(new Insets(0, 2, 0, 2));
    setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    this.direction = direction;
    this.arrowCount = arrowCount;
    this.arrowSize = arrowSize;
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    contentPane = new JPanel();

    setContentPane(contentPane);//from w w  w .j a v  a 2s  . co  m
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_panel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gbl_panel.columnWeights = new double[] { 0.0, 0.1, 0.0, Double.MIN_VALUE };
    gbl_panel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };

    contentPane.setLayout(gbl_panel);

    JButton btn_1 = new JButton("B1");
    GridBagConstraints gbc_comboBox = new GridBagConstraints();
    gbc_comboBox.insets = new Insets(0, 0, 5, 20);
    gbc_comboBox.gridx = 2;
    gbc_comboBox.gridy = 0;
    gbc_comboBox.weightx = 0.0;
    contentPane.add(btn_1, gbc_comboBox);

    JButton btn_2 = new JButton("B2");
    GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
    gbc_btnNewButton.insets = new Insets(0, 0, 5, 20);
    gbc_btnNewButton.gridx = 2;
    gbc_btnNewButton.gridy = 1;
    contentPane.add(btn_2, gbc_btnNewButton);
    setSize(200, 300);
}

From source file:SimpleBorder.java

public Insets getBorderInsets(Component c) {
    return new Insets(top, left, bottom, right);
}

From source file:BottomBorder.java

public Insets getBorderInsets(Component c) {
    return new Insets(0, 0, gap, 0);
}

From source file:ColorIcon.java

public ColorIcon(int width, int height, Color c) {
    iWidth = width;/*  w  w w .j a v a 2  s .co  m*/
    iHeight = height;

    color = c;
    border = Color.black;
    insets = new Insets(1, 1, 1, 1);
}

From source file:Main.java

public MyPanel() {
    JTextField labelA = new JTextField("Your A component");
    JTextField labelB = new JTextField("Your B component");
    JTextField labelC = new JTextField("Your C component");
    JTextField labelD = new JTextField("Top Right D");

    JPanel north = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.FIRST_LINE_END;
    gbc.weightx = 1;//w  ww.jav a  2  s  . c o  m
    gbc.insets = new Insets(10, 10, 10, 10);
    north.add(labelD, gbc);

    JPanel south = new JPanel(new GridBagLayout());
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridy = 0;
    south.add(labelA, gbc);
    gbc.gridy = 1;
    south.add(labelB, gbc);
    gbc.gridy = 2;
    south.add(labelC, gbc);

    setLayout(new BorderLayout());
    add(north, BorderLayout.NORTH);
    add(south, BorderLayout.CENTER);
}

From source file:Main.java

/**
 * Returns a styled JButton./*from   w ww.j  a  va 2s  .  c o m*/
 *
 * @param style button type
 * @return a styled button
 */
public static JButton creaStyledButton(int style) {
    JButton jb = new JButton();
    jb.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    jb.setMargin(new Insets(0, 5, 1, 5));
    switch (style) {
    case STYLE_EDIT: {
        jb.setText("edit");
        jb.setToolTipText("edit");
        jb.setPreferredSize(new Dimension(60, 30));
        return jb;
    }
    case STYLE_OK: {
        jb.setText("ok");
        jb.setToolTipText("confirm changes");
        jb.setPreferredSize(new Dimension(60, 30));
        return jb;
    }
    case STYLE_CANCEL: {
        jb.setText("cancel");
        jb.setToolTipText("discard changes");
        jb.setPreferredSize(new Dimension(60, 30));
        return jb;
    }
    case STYLE_INSBEFOREROW: {
        jb.setIcon(ICON_INSBEFOREROW);
        jb.setToolTipText("insert row before");
        jb.setName("INSBEFOREROW");
        return jb;
    }
    case STYLE_INSAFTERROW: {
        jb.setIcon(ICON_INSAFTERROW);
        jb.setToolTipText("insert row after");
        jb.setName("INSAFTERROW");
        return jb;
    }
    case STYLE_DELETEROW: {
        jb.setIcon(ICON_DELETEROW);
        jb.setToolTipText("delete row");
        jb.setName("DELETEROW");
        return jb;
    }
    case STYLE_CLONEBEFOREROW: {
        jb.setIcon(ICON_CLONEBEFOREROW);
        jb.setToolTipText("clone row before");
        jb.setName("CLONEBEFOREROW");
        return jb;
    }
    case STYLE_CLONEAFTERROW: {
        jb.setIcon(ICON_CLONEAFTERROW);
        jb.setToolTipText("clone row after");
        jb.setName("CLONEAFTERROW");
        return jb;
    }
    case STYLE_DEFAULTROWS: {
        jb.setIcon(ICON_DEFAULTROWS);
        jb.setToolTipText("set default values");
        jb.setName("DEFAULTROWS");
        return jb;
    }
    default: {
        return null;
    }
    }
}

From source file:RightSideBorder.java

/**
 * Returns the insets of the border.//from  w  w  w  . ja v a  2  s.  c om
 * @param c the component for which this border insets value applies
 */
public Insets getBorderInsets(Component c) {
    return new Insets(0, 0, 0, gap);
}