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:net.sf.jabref.wizard.auximport.gui.FromAuxDialog.java

private void jbInit() {
    JPanel panel1 = new JPanel();

    panel1.setLayout(new BorderLayout());
    selectInDBButton.setText(Localization.lang("Select"));
    selectInDBButton.setEnabled(false);/*  w w  w  .  j  a  v  a2 s  . c o m*/
    selectInDBButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            FromAuxDialog.this.select_actionPerformed();
        }
    });
    generateButton.setText(Localization.lang("Generate"));
    generateButton.setEnabled(false);
    generateButton.addActionListener(new FromAuxDialog_generate_actionAdapter(this));
    cancelButton.setText(Localization.lang("Cancel"));
    cancelButton.addActionListener(new FromAuxDialog_Cancel_actionAdapter(this));
    parseButton.setText(Localization.lang("Parse"));
    parseButton.addActionListener(new FromAuxDialog_parse_actionAdapter(this));

    initPanels();

    // insert the buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    JPanel buttonPanel = bb.getPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    bb.addGlue();
    bb.addButton(parseButton);
    bb.addRelatedGap();
    bb.addButton(selectInDBButton);
    bb.addButton(generateButton);
    bb.addButton(cancelButton);
    bb.addGlue();
    this.setModal(true);
    this.setResizable(true);
    this.setTitle(Localization.lang("AUX file import"));
    JLabel desc = new JLabel("<html><h3>" + Localization.lang("AUX file import") + "</h3><p>"
            + Localization.lang("This feature generates a new database based on which entries "
                    + "are needed in an existing LaTeX document.")
            + "</p>" + "<p>"
            + Localization.lang("You need to select one of your open databases from which to choose "
                    + "entries, as well as the AUX file produced by LaTeX when compiling your document.")
            + "</p></html>");
    desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.add(desc, BorderLayout.NORTH);

    JPanel centerPane = new JPanel(new BorderLayout());
    centerPane.add(buttons, BorderLayout.NORTH);
    centerPane.add(statusPanel, BorderLayout.CENTER);

    getContentPane().add(panel1, BorderLayout.NORTH);
    getContentPane().add(centerPane, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    // Key bindings:
    ActionMap am = statusPanel.getActionMap();
    InputMap im = statusPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });

}

From source file:TextInputDemo.java

protected JComponent createAddressDisplay() {
    JPanel panel = new JPanel(new BorderLayout());
    addressDisplay = new JLabel();
    addressDisplay.setHorizontalAlignment(JLabel.CENTER);
    regularFont = addressDisplay.getFont().deriveFont(Font.PLAIN, 16.0f);
    italicFont = regularFont.deriveFont(Font.ITALIC);
    updateDisplays();//from  w  w  w.ja va 2s  .c  o m

    //Lay out the panel.
    panel.setBorder(BorderFactory.createEmptyBorder(GAP / 2, //top
            0, //left
            GAP / 2, //bottom
            0)); //right
    panel.add(new JSeparator(JSeparator.VERTICAL), BorderLayout.LINE_START);
    panel.add(addressDisplay, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(200, 150));

    return panel;
}

From source file:com.intel.stl.ui.common.view.ChartsSectionView.java

@Override
protected JComponent getMainComponent() {
    if (mainPanel == null) {
        mainPanel = new JPanel();
        mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 2, 2, 2));
    }//from   w  w w .j  a v  a2s . co m
    return mainPanel;
}

From source file:SwingCheckBoxDemo.java

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

    //Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);/*from  ww  w.  j  a  va  2 s.  c  o  m*/

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    //Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    //Indicates what's on the geek.
    choices = new StringBuffer("cght");

    //Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    /*Put the check boxes in a column in a panel*/

    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

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

private final JPanel getMainPanel() {
    final JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
    final ServerList linkedServerList = new ServerList(linkedServerListModel);
    linkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    final JScrollPane linkedServerScrollPane = new JScrollPane(linkedServerList);
    linkedServerScrollPane/*from  www. j av a2s.co  m*/
            .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Linked Servers"));
    // Doesn't matter what this is set to, as long as it's the same as the
    // one for unlinkedServerScrollPane
    linkedServerScrollPane.setPreferredSize(new Dimension(10, 10));

    final GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 1.0;

    mainPanel.add(linkedServerScrollPane, c);

    final ServerList unlinkedServerList = new ServerList(unlinkedServerListModel);
    unlinkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    final JScrollPane unlinkedServerScrollPane = new JScrollPane(unlinkedServerList);
    unlinkedServerScrollPane
            .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Unlinked Servers"));

    // Doesn't matter what this is set to, as long as it's the same as the
    // one for unlinkedServerScrollPane
    unlinkedServerScrollPane.setPreferredSize(new Dimension(10, 10));

    final JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new BoxLayout(middlePanel, BoxLayout.Y_AXIS));
    middlePanel.add(Box.createVerticalGlue());

    final JButton linkSelectionButton = new JButton("<");
    final JButton unlinkSelectionButton = new JButton(">");

    linkSelectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            // Move selection from unlinked to linked list
            final int selection = unlinkedServerList.getSelectedIndex();

            if (selection < 0) {
                return;
            }

            final Server server = unlinkedServerListModel.getVisibleServerAtIndex(selection);

            unlinkedServerListModel.removeServer(server);

            linkedServerListModel.addServer(server);
        }
    });

    unlinkSelectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            // Move selection from linked to unlinked list
            final int selection = linkedServerList.getSelectedIndex();

            if (selection < 0) {
                return;
            }

            final int answer = JOptionPane.showOptionDialog(LinkUnlinkWindow.this,
                    "You are about to unlink a server. "
                            + "Unlinking a server will permanently remove \nall data associated with "
                            + "this server, but the server will keep running. "
                            + "\n\nAre you sure you wish to continue?",
                    "Unlink Server", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null);

            if (answer != JOptionPane.YES_OPTION) {
                return;
            }

            final Server server = linkedServerListModel.getVisibleServerAtIndex(selection);

            linkedServerListModel.removeServer(server);

            unlinkedServerListModel.addServer(server);
        }
    });

    middlePanel.add(unlinkSelectionButton);
    middlePanel.add(Box.createVerticalStrut(10));
    middlePanel.add(linkSelectionButton);
    middlePanel.add(Box.createVerticalGlue());

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;

    mainPanel.add(middlePanel, c);

    c.gridx = 2;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 1.0;

    mainPanel.add(unlinkedServerScrollPane, c);
    return mainPanel;
}

From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java

private JPanel createCurvesPanel() {
    JPanel wrap = new JPanel(new BorderLayout());
    JPanel curves = new JPanel(new BorderLayout());
    curves.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //      JPanel general = new JPanel(new BorderLayout());
    //      general.setBorder(BorderFactory.createTitledBorder(
    //            BorderFactory.createEtchedBorder(), "General"));
    ////  www .  j a  v  a  2 s.c o m
    //      JPanel inner = new JPanel(new LCBLayout(6));
    //      inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    //
    //      inner.add(new JLabel("Show Marker"));
    //      showMarker = new JCheckBox();
    //      showMarker.setActionCommand(SHOW_MARKER_COMMAND);
    //      showMarker.addActionListener(this);
    //      inner.add(showMarker);
    //      inner.add(new JLabel());

    //      inner.add(new JLabel("Show Error"));
    //      showError = new JCheckBox();
    //      showError.setActionCommand(SHOW_ERROR_COMMAND);
    //      showError.addActionListener(this);
    //      inner.add(showError);
    //      inner.add(new JLabel());
    //
    //      general.add(inner, BorderLayout.NORTH);
    //      curves.add(general, BorderLayout.NORTH);

    JPanel individual = new JPanel(new BorderLayout());
    individual.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Individual Curve"));

    JPanel interior = new JPanel(new LCBLayout(7));
    interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    int numberOfDataset = chart.getXYPlot().getDatasetCount();
    currentDataset = null;
    currentSeriesIndex = -1;
    List<String> seriesNames = new ArrayList<String>();
    for (int i = 0; i < numberOfDataset; i++) {
        XYDataset dataset = chart.getXYPlot().getDataset(i);
        if (dataset != null && dataset instanceof ITimeSeriesSet) {
            int numberOfSeries = dataset.getSeriesCount();
            for (int j = 0; j < numberOfSeries; j++) {
                String seriesName = (String) dataset.getSeriesKey(j);
                seriesNames.add(seriesName);
                if (seriesName.equals(currentSeriesKey)) {
                    currentDataset = (IDataset) dataset;
                    currentSeriesIndex = j;
                }
            }
        }
    }
    if ((currentDataset == null || currentSeriesIndex < 0) && seriesNames.size() > 0) {
        for (int i = 0; i < numberOfDataset; i++) {
            XYDataset dataset = chart.getXYPlot().getDataset(i);
            if (dataset != null && dataset instanceof ITimeSeriesSet && dataset.getSeriesCount() > 0) {
                currentDataset = (IDataset) dataset;
                currentSeriesIndex = 0;
                currentSeriesKey = (String) dataset.getSeriesKey(currentSeriesIndex);
                break;
            }
        }
    }

    //Select curve combo
    this.seriesCombo = new JComboBox(seriesNames.toArray());
    seriesCombo.setActionCommand(CHANGE_CURVE_COMMAND);
    seriesCombo.addActionListener(this);
    interior.add(new JLabel("Select Curve"));
    interior.add(seriesCombo);
    interior.add(new JLabel(""));

    interior.add(new JLabel("Curve Stroke"));
    curveStrokeSample = new StrokeSample(new BasicStroke());
    curveStrokeSample.setEnabled(false);
    interior.add(curveStrokeSample);
    //      JButton button = new JButton(localizationResources.getString("Edit..."));
    Float[] strokes = new Float[] { 0f, 0.2f, 0.5f, 1f, 1.5f, 2f, 3f };
    strokeCombo = new JComboBox(strokes);
    strokeCombo.setActionCommand(CURVE_STROCK_COMMAND);
    strokeCombo.addActionListener(this);
    interior.add(strokeCombo);

    interior.add(new JLabel("Curve Colour"));
    curveColorPaint = new PaintSample(chart.getBackgroundPaint());
    interior.add(curveColorPaint);
    JButton button = new JButton(localizationResources.getString("Edit..."));
    button.setActionCommand(CURVE_COLOR_COMMAND);
    button.addActionListener(this);
    interior.add(button);

    interior.add(new JLabel("Marker Visible"));
    showMarker = new JCheckBox();
    showMarker.setActionCommand(SHOW_MARKER_COMMAND);
    showMarker.addActionListener(this);
    interior.add(showMarker);
    interior.add(new JLabel());

    interior.add(new JLabel("Marker Shape"));
    shapeLabel = new JLabel();
    interior.add(shapeLabel);
    Integer[] shapeIndex = new Integer[MarkerShape.size];
    for (int i = 0; i < shapeIndex.length; i++) {
        shapeIndex[i] = i;
    }
    shapeCombo = new JComboBox(shapeIndex);
    comboRender = new ImageComboRender();
    comboRender.setShapes(StaticValues.LOCAL_SHAPE_SERIES);
    shapeCombo.setRenderer(comboRender);
    shapeCombo.setMaximumRowCount(7);
    shapeCombo.setActionCommand(MARKER_SHAPE_COMMAND);
    shapeCombo.addActionListener(this);
    interior.add(shapeCombo);

    interior.add(new JLabel("Marker Filled"));
    markerFilled = new JCheckBox();
    markerFilled.setActionCommand(MARKER_FILLED_COMMAND);
    markerFilled.addActionListener(this);
    interior.add(markerFilled);
    interior.add(new JLabel());

    interior.add(new JLabel("Curve Visable"));
    curveVisable = new JCheckBox();
    curveVisable.setActionCommand(CURVE_VISIBLE_COMMAND);
    curveVisable.addActionListener(this);
    interior.add(curveVisable);
    interior.add(new JLabel());

    individual.add(interior, BorderLayout.NORTH);
    curves.add(individual, BorderLayout.NORTH);
    curves.setName("Curves");
    wrap.setName("Curves");
    wrap.add(curves, BorderLayout.NORTH);
    return wrap;
}

From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java

/**
 * Constructs the latency plotter/*from  w  ww .  j  ava2s  .  c  om*/
 * 
 * @param title
 *            the frame title.
 */
public BestCostPlotter(final String title, Semaphore pauseSemaphore) {

    super(title);

    JFreeChart chart = createChart(title);
    final JPanel content = new JPanel(new BorderLayout());

    chartPanel = new ChartPanel(chart);
    content.add(chartPanel);

    final JPanel buttonPanel = new JPanel(new FlowLayout());

    final JButton buttonPause = new JButton("Pause");
    buttonPause.setActionCommand("pause");
    buttonPause.addActionListener(this);
    buttonPanel.add(buttonPause);

    final JButton buttonAll = new JButton("Stop");
    buttonAll.setActionCommand("ADD_ALL");
    buttonAll.addActionListener(this);
    buttonPanel.add(buttonAll);

    final JButton buttonLecture = new JButton("Resume");
    buttonLecture.setActionCommand("Resume");
    buttonLecture.addActionListener(this);
    buttonPanel.add(buttonLecture);

    content.add(buttonPanel, BorderLayout.SOUTH);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 470));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setContentPane(content);

    this.pauseSemaphore = pauseSemaphore;
}

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

private JPanel getSearchPanel(final TableRowSorter<MachineImageTableModel> sorter) {
    final JPanel searchPanel = new JPanel(new GridBagLayout());
    searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));

    add(searchPanel, BorderLayout.NORTH);
    final PlatformComboBox platformComboBox = new PlatformComboBox();

    final GridBagConstraints c = new GridBagConstraints();
    c.weightx = 0.0;/*from w  ww .j  av a 2  s .  c  om*/
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 5);

    searchPanel.add(platformComboBox, c);
    final ArchitectureComboBox architectureComboBox = new ArchitectureComboBox();

    c.gridx = 1;
    searchPanel.add(architectureComboBox, c);

    final BetterTextField searchField = new BetterTextField();
    searchField.setPlaceHolder("Search terms");

    searchField.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    c.gridx = 2;
    c.weightx = 1.0;
    c.insets = new Insets(0, 0, 0, 0);
    searchPanel.add(searchField, c);

    searchField.addActionListener(
            new SearchFieldListener(architectureComboBox, sorter, platformComboBox, searchField));

    return searchPanel;
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultNumberAxisEditor.java

/**
 * Standard constructor: builds a property panel for the specified axis.
 * /*from ww w  .j av  a2  s. co  m*/
 * @param axis
 *            the axis, which should be changed.
 */
public DefaultNumberAxisEditor(NumberAxis axis) {
    super(axis);

    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();

    this.gridPaintSample = new PaintSample(Color.blue);
    this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f));

    this.availableStrokeSamples = new StrokeSample[3];
    this.availableStrokeSamples[0] = new StrokeSample(new BasicStroke(1.0f));
    this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(2.0f));
    this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(3.0f));

    JTabbedPane other = getOtherTabs();

    JPanel range = new JPanel(new LCBLayout(3));
    range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    range.add(new JPanel());
    this.autoRangeCheckBox = new JCheckBox(localizationResources.getString("Auto-adjust_range"),
            this.autoRange);
    this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff");
    this.autoRangeCheckBox.addActionListener(this);
    range.add(this.autoRangeCheckBox);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString("Minimum_range_value")));
    this.minimumRangeValue = new JTextField(Double.toString(this.minimumValue));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    this.minimumRangeValue.setActionCommand("MinimumRange");
    this.minimumRangeValue.addActionListener(this);
    this.minimumRangeValue.addFocusListener(this);
    range.add(this.minimumRangeValue);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString("Maximum_range_value")));
    this.maximumRangeValue = new JTextField(Double.toString(this.maximumValue));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    this.maximumRangeValue.setActionCommand("MaximumRange");
    this.maximumRangeValue.addActionListener(this);
    this.maximumRangeValue.addFocusListener(this);
    range.add(this.maximumRangeValue);
    range.add(new JPanel());

    other.add(localizationResources.getString("Range"), range);

}

From source file:com.intuit.tank.tools.debugger.PanelBuilder.java

/**
 * @param debuggerActions/*from  ww  w.j a v a  2s .  c  o  m*/
 * @return
 */
static Component createContentPanel(final AgentDebuggerFrame frame) {
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    final RSyntaxTextArea scriptEditorTA = new RSyntaxTextArea();
    frame.setScriptEditorTA(scriptEditorTA);
    scriptEditorTA.setSelectionColor(scriptEditorTA.getCurrentLineHighlightColor());
    scriptEditorTA.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    scriptEditorTA.setHyperlinksEnabled(false);
    scriptEditorTA.setEditable(false);
    scriptEditorTA.setEnabled(false);
    scriptEditorTA.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            scriptEditorTA.grabFocus();
            try {
                int offs = scriptEditorTA.viewToModel(e.getPoint());
                if (offs > -1) {
                    int line = scriptEditorTA.getLineOfOffset(offs);
                    if (frame.getSteps().size() > line) {

                        frame.fireStepChanged(line);
                        if (e.getClickCount() == 2 && !e.isPopupTrigger()) {
                            // show step xml
                            try {
                                DebugStep debugStep = frame.getSteps().get(line);
                                String text = JaxbUtil.marshall(debugStep.getStepRun());
                                StepDialog dlg = new StepDialog(frame, text, SyntaxConstants.SYNTAX_STYLE_XML);
                                dlg.setVisible(true);
                            } catch (JAXBException e1) {
                                frame.showError("Error showing step xml: " + e);
                            }
                        }
                    }
                }
            } catch (BadLocationException ble) {
                ble.printStackTrace(); // Never happens
            }
        }
    });
    RTextScrollPane scriptEditorScrollPane = new RTextScrollPane(scriptEditorTA);
    frame.setScriptEditorScrollPane(scriptEditorScrollPane);
    scriptEditorScrollPane.setIconRowHeaderEnabled(true);
    scriptEditorScrollPane.getGutter()
            .setBookmarkIcon(ActionProducer.getIcon("bullet_blue.png", IconSize.SMALL));
    scriptEditorScrollPane.getGutter()
            .setCurrentLineIcon(ActionProducer.getIcon("current_line.png", IconSize.SMALL));
    scriptEditorScrollPane.getGutter().setBookmarkingEnabled(true);
    pane.setLeftComponent(scriptEditorScrollPane);

    pane.setRightComponent(createRightPanel(frame));
    pane.setDividerLocation(300);
    pane.setResizeWeight(0.4D);
    return pane;
}