Example usage for javax.swing BorderFactory createEmptyBorder

List of usage examples for javax.swing BorderFactory createEmptyBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createEmptyBorder.

Prototype

public static Border createEmptyBorder(int top, int left, int bottom, int right) 

Source Link

Document

Creates an empty border that takes up space but which does no drawing, specifying the width of the top, left, bottom, and right sides.

Usage

From source file:components.ListDialogRunner.java

public static JPanel createUI() {
    //Create the labels.
    JLabel intro = new JLabel("The chosen name:");
    final JLabel name = new JLabel(names[1]);
    intro.setLabelFor(name);/*w  w  w .j ava2 s  .  com*/

    //Use a wacky font if it exists. If not, this falls
    //back to a font we know exists.
    name.setFont(getAFont());

    //Create the button.
    final JButton button = new JButton("Pick a new name...");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String selectedName = ListDialog.showDialog(frame, button, "Baby names ending in O:",
                    "Name Chooser", names, name.getText(), "Cosmo  ");
            name.setText(selectedName);
        }
    });

    //Create the panel we'll return and set up the layout.
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20));
    intro.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    name.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    button.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    //Add the labels to the content pane.
    panel.add(intro);
    panel.add(Box.createVerticalStrut(5)); //extra space
    panel.add(name);

    //Add a vertical spacer that also guarantees us a minimum width:
    panel.add(Box.createRigidArea(new Dimension(150, 10)));

    //Add the button.
    panel.add(button);

    return panel;
}

From source file:com.game.ui.views.WeaponEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new "
                    + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);/*  ww w.j ava2  s. c  om*/
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Item item : GameBean.weaponDetails) {
        if (item instanceof Weapon) {
            model.addElement(((Weapon) item).getName());
        }
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel weaponDtsLbl = new JLabel("Weapon Details : ");
    weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(weaponDtsLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel weaponTypeLbl = new JLabel("Weapon Type : ");
    panel1.add(weaponTypeLbl, c);
    c.gridx = 1;
    JComboBox weaponType = new JComboBox(Configuration.weaponTypes);
    weaponType.setSelectedIndex(0);
    weaponType.setPreferredSize(name.getPreferredSize());
    System.out.println(name.getPreferredSize());
    panel1.add(weaponType, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel attackRangeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRangeLbl, c);
    c.gridx = 1;
    JTextField attackRange = new JTextField("");
    attackRange.setColumns(20);
    panel1.add(attackRange, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    //        c.fill = GridBagConstraints.BOTH;
    //        c.gridy = 7;
    //        c.weightx = 1;
    //        c.weighty = 1;
    //        panel1.add(new JLabel(""), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}

From source file:com.choicemaker.cm.modelmaker.gui.panels.AsymmetricThresholdVsAccuracyPlotPanel.java

public AsymmetricThresholdVsAccuracyPlotPanel(TestingControlPanel g) {
    super();//w w  w .j a  v a 2  s.c o  m
    parent = g;
    setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5));
    buildPlots();
    layoutPanel();
    addListeners();
}

From source file:corina.gui.ErrorLog.java

private ErrorLog() {
    setTitle("Log");
    LogViewer center = new LogViewer();

    // WRITEME: to add printing, make a Printer that just calls
    // lines.add(line) for each |line| read from w.toString(),
    // and also call the java/awt printing method.

    center.setBorder(BorderFactory.createEmptyBorder(14, 14, 14, 14));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    getContentPane().add(center, BorderLayout.CENTER);
    pack();//from w w w. j  a v  a 2  s .  c o  m
    setSize(600, 500);
}

From source file:hermes.browser.dialog.BeanPropertyPanel.java

protected JComponent createNorthComponent() {
    JLabel classNameLabel = new JLabel("Class: " + bean.getClass().getName());
    classNameLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    return classNameLabel;
}

From source file:de.tbuchloh.kiskis.gui.dialogs.ImportDialog.java

private static void addPadding(final JPanel panel) {
    panel.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
}

From source file:edu.ku.brc.af.ui.db.TextFieldFromPickListTable.java

/**
 * Constructor.//w  w w. j a  v  a 2  s .c  o  m
 * @param adapter the PickListTableAdapter
 */
public TextFieldFromPickListTable(final PickListDBAdapterIFace adapter, final int cols) {
    super(Math.max(cols, 10));

    setControlSize(this);

    this.adapter = adapter;

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
}

From source file:QandE.Test1.java

public Component createComponents() {
    final JLabel label = new JLabel(labelText);

    /*/* w ww . j  av a  2 s  .co m*/
     * An easy way to put space between a top-level container
     * and its contents is to put the contents in a JPanel
     * that has an "empty" border.
     */
    JPanel pane = new JPanel();
    pane.setBorder(BorderFactory.createEmptyBorder(30, //top
            30, //left
            10, //bottom
            30) //right
    );
    pane.setLayout(new GridLayout(0, 1));
    pane.add(label);

    return pane;
}

From source file:org.pgptool.gui.ui.importkey.KeyImporterView.java

private JPanel buildPanelButtons() {
    JPanel ret = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    ret.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
    ret.add(btnImport = new JButton());
    ret.add(btnCancel = new JButton());
    return ret;/*from   www .ja  v a 2  s . co  m*/
}

From source file:dnd.TextCutPaste.java

public TextCutPaste() {
    super(new BorderLayout());

    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    //Create the transfer handler.
    TextTransferHandler th = new TextTransferHandler();

    //Create some text fields.
    JPanel buttonPanel = new JPanel(new GridLayout(3, 1));
    JTextField textField = new JTextField("Cut, copy and paste...", 30);
    textField.setTransferHandler(th);/*w w  w.java2s  .com*/
    textField.setDragEnabled(true);
    buttonPanel.add(textField);
    textField = new JTextField("or drag and drop...", 30);
    textField.setTransferHandler(th);
    textField.setDragEnabled(true);
    buttonPanel.add(textField);
    textField = new JTextField("from any of these text fields.", 30);
    textField.setTransferHandler(th);
    textField.setDragEnabled(true);
    buttonPanel.add(textField);
    add(buttonPanel, BorderLayout.CENTER);
}