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:org.gumtree.vis.awt.AbstractPlotEditor.java

/**
 * Standard constructor - the property panel is made up of a number of
 * sub-panels that are displayed in the tabbed pane.
 *
 * @param chart  the chart, whichs properties should be changed.
 *///from  w  w  w .ja  va2 s  . c o m
public AbstractPlotEditor(IPlot plot) {
    setLayout(new BorderLayout());
    this.plot = plot;
    JPanel parts = new JPanel(new BorderLayout());
    tabs = new JTabbedPane();

    helpPanel = createHelpPanel();
    helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    tabs.addTab("Help", helpPanel);

    parts.add(tabs, BorderLayout.NORTH);
    add(parts);
}

From source file:Main.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    if (isSelected) {
        setBackground(UIManager.getColor("Table.selectionBackground"));
    }//from w ww . j  ava 2s .  co  m

    if (hasFocus) {
        setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));

        if (table.isCellEditable(row, column)) {
            super.setForeground(UIManager.getColor("Table.focusCellForeground"));
            super.setBackground(UIManager.getColor("Table.focusCellBackground"));
        }
    } else {
        setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    }
    setText((String) (value));
    table.setRowHeight(row, getPreferredSize().height + row * 10);
    return this;
}

From source file:lookandfeel.SynthDialog.java

public SynthDialog() {
   JLabel label = new JLabel("Find What:");;
    JTextField textField = new JTextField();
    JCheckBox caseCheckBox = new JCheckBox("Match Case");
    JCheckBox wrapCheckBox = new JCheckBox("Wrap Around");
    JCheckBox wholeCheckBox = new JCheckBox("Whole Words");
    JCheckBox backCheckBox = new JCheckBox("Search Backwards");
    JButton findButton = new JButton("Find");
    JButton cancelButton = new JButton("Cancel");

    // remove redundant default border of check boxes - they would hinder
    // correct spacing and aligning (maybe not needed on some look and feels)
    caseCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wrapCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wholeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    backCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);//  w  ww .ja va 2  s  .c o m
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(layout.createSequentialGroup()
        .addComponent(label)
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(textField)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(caseCheckBox)
                    .addComponent(wholeCheckBox))
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(wrapCheckBox)
                    .addComponent(backCheckBox))))
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(findButton)
            .addComponent(cancelButton))
    );
       
    layout.linkSize(SwingConstants.HORIZONTAL, findButton, cancelButton);

    layout.setVerticalGroup(layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(BASELINE)
            .addComponent(label)
            .addComponent(textField)
            .addComponent(findButton))
        .addGroup(layout.createParallelGroup(LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(caseCheckBox)
                    .addComponent(wrapCheckBox))
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(wholeCheckBox)
                    .addComponent(backCheckBox)))
            .addComponent(cancelButton))
    );

    setTitle("Find");
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

From source file:mergedoc.ui.PreferencePanel.java

/**
 * ??//from   w  w  w .j a v  a  2 s  .com
 * @throws MergeDocException ????????
 */
public PreferencePanel() throws MergeDocException {

    // 
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setMaximumSize(ComponentFactory.createMaxDimension());

    // ????
    add(createUpperPanel());
    add(ComponentFactory.createSpacer(0, 7));
    add(createLowerPanel());
}

From source file:org.apache.taverna.activities.xpath.ui.config.XPathActivityConfigurationPanelProvider.java

@Override
protected void initialise() {
    super.initialise();
    removeAll();/*from w ww  . ja  v  a  2  s  . c  om*/
    setLayout(new BorderLayout());

    // create actual contents of the config panel
    this.configPanel = new XPathActivityConfigurationPanel();
    add(configPanel, BorderLayout.CENTER);

    // place the whole configuration panel into a raised area, so that
    // automatically added 'Apply' / 'Close' buttons visually apply to
    // the whole of the panel, not just part of it
    this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(12, 12, 2, 12),
            BorderFactory.createRaisedBevelBorder()));

    // Populate fields from activity configuration bean
    refreshConfiguration();
}

From source file:components.BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    //Keep references to the next few borders,
    //for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    //A border that puts 10 extra pixels at the sides and
    //bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    //First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);/* w w  w . java  2 s .c  om*/
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    //Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    //Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    //Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    // Keep references to the next few borders,
    // for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    // A border that puts 10 extra pixels at the sides and
    // bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    // First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);//from   w w  w .j  av a2s.c o m
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    // Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    // Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    // Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    listModel.addElement("A");
    listModel.addElement("B");
    listModel.addElement("C");

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);//ww  w  . jav a  2 s.c om
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(addCommand);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(addCommand);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    fireButton = new JButton(deleteCommand);
    fireButton.setActionCommand(deleteCommand);
    fireButton.addActionListener(new FireListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();
    System.out.println(name);

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
}

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

public HoldVsAccuracyPlotPanel(TestingControlPanel g) {
    super();
    parent = g;
    setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5));
    buildPanel();
    layoutPanel();
    setAccErrs();
}

From source file:SynthApplication.java

public Component createComponents() {
    JButton button = new JButton("I'm a Swing button!");
    button.setMnemonic(KeyEvent.VK_I);
    button.addActionListener(this);
    label.setLabelFor(button);//from w ww.  ja va  2 s .  c o 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(new GridLayout(0, 1));
    pane.add(button);
    pane.add(label);
    pane.setBorder(BorderFactory.createEmptyBorder(30, //top
            30, //left
            10, //bottom
            30) //right
    );

    return pane;
}