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:com.idealista.solrmeter.view.statistic.PieChartPanel.java

private Component createCustomizePanel() {
    JButton jButtonCustomize = new JButton(I18n.get("statistic.pieChartPanel.customize"));
    jButtonCustomize.addActionListener(new ActionListener() {

        @Override/*from   ww  w.  j  a  va 2 s.c  o  m*/
        public void actionPerformed(ActionEvent e) {
            JDialogCustomizePieChart dialog = new JDialogCustomizePieChart(SolrMeterMain.mainFrame,
                    timeRangeStatistic);
            dialog.setVisible(true);
        }

    });

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 10));
    panel.add(Box.createHorizontalGlue());
    panel.add(jButtonCustomize);

    return panel;
}

From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedCommunicationPanel.java

final public void clearAndFill(final Collection<Server> selectedServers) {

    // Remove all components on there
    invalidate();/*from w  ww. j a  v  a  2s. c om*/
    removeAll();

    setLayout(new BorderLayout());

    // If there are no servers, or none of the servers are running, do not
    // display the ssh console
    final Collection<Server> connectableServers = new ArrayList<Server>();
    for (final Server s : selectedServers) {
        if (s.getStatus() == VmState.RUNNING && s.getPublicDnsAddress() != null) {
            connectableServers.add(s);
        }
    }

    // If there are no servers to connect to, don't draw the ssh console
    if (connectableServers.size() == 0) {
        log.info("Connection tab clicked and no servers selected to connect to.");
        final BetterTextLabel txt = new BetterTextLabel(
                "Please select at least one running server to connect to.");
        txt.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        add(txt, BorderLayout.CENTER);
        validate();
        repaint();
    } else {
        final Server connectServer = selectedServers.iterator().next();

        final JPanel propertiesPanel = new JPanel();
        propertiesPanel.setLayout(new BoxLayout(propertiesPanel, BoxLayout.LINE_AXIS));
        propertiesPanel.add(Box.createHorizontalGlue());
        final JButton propertiesButton = new JButton("Properties", Utils.icon("modify16.png"));
        propertiesButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                final ChangeServerSshLoginMethodWindow win = new ChangeServerSshLoginMethodWindow(parent,
                        connectServer);
                win.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        clearAndFill(selectedServers);
                    }
                });
                win.setVisible(true);
            }
        });

        final JButton restartButton = new JButton("Restart connection", Utils.icon("undo16.png"));
        restartButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                clearAndFill(selectedServers);
            }
        });
        propertiesPanel.add(restartButton);
        propertiesPanel.add(Box.createHorizontalStrut(10));
        propertiesPanel.add(propertiesButton);
        propertiesPanel.add(Box.createHorizontalStrut(20));
        propertiesPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        add(propertiesPanel, BorderLayout.NORTH);

        final SSHPanel sshPanel = new SSHPanel(connectServer);
        sshPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 10, 20));
        add(sshPanel, BorderLayout.CENTER);

        validate();
        repaint();
    }
}

From source file:ComboBoxDemo.java

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

    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };

    //Create the combo box, select the item at index 4.
    //Indices start at 0, so 4 specifies the pig.
    JComboBox petList = new JComboBox(petStrings);
    petList.setSelectedIndex(4);// www  .  j a  va 2s.  c  o  m
    petList.addActionListener(this);

    //Set up the picture.
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);
    updateLabel(petStrings[petList.getSelectedIndex()]);
    picture.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //The preferred size is hard-coded to be the width of the
    //widest image and the height of the tallest image + the border.
    //A real program would compute this.
    picture.setPreferredSize(new Dimension(177, 122 + 10));

    //Lay out the demo.
    add(petList, BorderLayout.PAGE_START);
    add(picture, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:VoteDialog.java

public VoteDialog(JFrame frame) {
    this.frame = frame;
    JLabel title;/*from   w w w  . j  a v a 2 s  .  c  om*/

    // Create the components.
    JPanel choicePanel = createSimpleDialogBox();

    System.out.println("passed createSimpleDialogBox");

    title = new JLabel("Click the \"Vote\" button" + " once you have selected a candidate.", JLabel.CENTER);

    label = new JLabel("Vote now!", JLabel.CENTER);
    label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    choicePanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 20));

    // Set the layout.
    setLayout(new BorderLayout());
    add(title, BorderLayout.NORTH);
    add(label, BorderLayout.SOUTH);
    add(choicePanel, BorderLayout.CENTER);
}

From source file:events.TreeExpandEventDemo.java

public TreeExpandEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;//from  www .  j  a va  2 s .c om
    c.weighty = 1.0;

    c.insets = new Insets(1, 1, 1, 1);
    demoArea = new DemoArea();
    gridbag.setConstraints(demoArea, c);
    add(demoArea);

    c.insets = new Insets(0, 0, 0, 0);
    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(200, 75));
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    setPreferredSize(new Dimension(450, 450));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:Main.java

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

    listModel = new DefaultListModel();
    listModel.addElement("Debbie Scott");
    listModel.addElement("Scott Hommel");
    listModel.addElement("Sharon Zakhour");

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);/*from w ww . ja  v a  2  s . c o  m*/
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

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

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

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

    // 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:ecosim.gui.SummaryPane.java

public SummaryPane(Summary summary) {
    this.summary = summary;
    setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    setLayout(new GridBagLayout());
    // Setup the constraints for the GridBagLayout.
    GridBagConstraints northWest = new GridBagConstraints(0, 0, // gridx, gridy
            1, 1, // gridwidth, gridheight
            0.9D, 0.9D, // weightx, weighty
            GridBagConstraints.CENTER, // anchor
            GridBagConstraints.BOTH, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );/*from  w w w .j a  va 2  s  .c om*/
    GridBagConstraints northEast = new GridBagConstraints(1, 0, // gridx, gridy
            1, 1, // gridwidth, gridheight
            0.1D, 0.5D, // weightx, weighty
            GridBagConstraints.NORTH, // anchor
            GridBagConstraints.HORIZONTAL, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );
    GridBagConstraints south = new GridBagConstraints(0, 1, // gridx, gridy
            2, 1, // gridwidth, gridheight
            1.0D, 0.1D, // weightx, weighty
            GridBagConstraints.SOUTH, // anchor
            GridBagConstraints.HORIZONTAL, // fill
            new Insets(0, 0, 0, 0), // insets
            0, 0 // ipadx, ipady
    );
    // Add everything to the summary pane.
    add(makeBinningChart(), northWest);
    add(makeTextPane(), northEast);
    add(makeTablePane(), south);
}

From source file: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);/*from  w w  w .j av a  2 s. c  om*/
    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);
}

From source file:org.gumtree.vis.awt.AbstractPlotEditor.java

private JPanel createHelpPanel() {
    JPanel wrap = new JPanel(new GridLayout(1, 1));

    JPanel helpPanel = new JPanel(new GridLayout(1, 1));
    helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    //       helpPanel.setBorder(BorderFactory.createTitledBorder(
    //            BorderFactory.createEtchedBorder(), "Help Topics"));

    SpringLayout spring = new SpringLayout();
    JPanel inner = new JPanel(spring);
    inner.setBorder(BorderFactory.createEmptyBorder());

    final IHelpProvider provider = plot.getHelpProvider();
    final JList list = new JList(provider.getHelpMap().keySet().toArray());
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //      list.setBorder(BorderFactory.createEtchedBorder());
    JScrollPane listPane1 = new JScrollPane(list);
    inner.add(listPane1);/*from w  w w.j a  v  a  2  s. c o m*/
    listPane1.setMaximumSize(new Dimension(140, 0));
    listPane1.setMinimumSize(new Dimension(70, 0));
    //      JPanel contentPanel = new JPanel(new GridLayout(2, 1));
    //      inner.add(list);
    final JTextField keyField = new JTextField();
    keyField.setMaximumSize(new Dimension(400, 20));
    keyField.setEditable(false);
    //      keyField.setMaximumSize();
    //      keyArea.setLineWrap(true);
    //      keyArea.setWrapStyleWord(true);
    //      keyArea.setBorder(BorderFactory.createEtchedBorder());
    inner.add(keyField);
    //      contentPanel.add(new JLabel());
    //      contentPanel.add(new JLabel());
    final JTextArea helpArea = new JTextArea();
    JScrollPane areaPane = new JScrollPane(helpArea);
    helpArea.setEditable(false);
    helpArea.setLineWrap(true);
    helpArea.setWrapStyleWord(true);
    //      helpArea.setBorder(BorderFactory.createEtchedBorder());
    inner.add(areaPane);
    //      contentPanel.add(new JLabel());
    //      contentPanel.add(new JLabel());
    //      inner.add(contentPanel);
    spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner);
    spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner);
    spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1);
    spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner);
    spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField);
    spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1);
    spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField);
    spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner);
    spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane);
    spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner);

    list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            Object[] selected = list.getSelectedValues();
            if (selected.length >= 0) {
                HelpObject help = provider.getHelpMap().get(selected[0]);
                if (help != null) {
                    keyField.setText(help.getKey());
                    helpArea.setText(help.getDiscription());
                }
            }
        }
    });

    helpPanel.add(inner, BorderLayout.NORTH);
    wrap.setName("Help");

    wrap.add(helpPanel, BorderLayout.NORTH);
    return wrap;
}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * {@inheritDoc}//from w w w  .j  a va  2 s  . c  o m
 */
@Override
protected void buildGUI() {
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Create the transaction and status labels
    Insets insets5 = new Insets(5, 5, 5, 5);
    add(bold(new JLabel("Transaction ID:")),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    add(transactionTxt, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    add(bold(new JLabel("Latest status:")),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    add(statusTxt, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // Create the info panel
    JPanel infoPanel = createInfoPanel();
    add(infoPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // Create the messages panel
    JScrollPane scrollPane = new JScrollPane(messagesPanel);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("Separator.shadow")));
    messagesPanel.setBackground(UIManager.getColor("List.background"));
    add(scrollPane, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0));
}