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.gui.journals.ManageJournalsPanel.java

public ManageJournalsPanel(final JabRefFrame frame) {
    this.frame = frame;

    personalFile.setEditable(false);//from   w w  w  .  j a v  a  2  s . c o m

    ButtonGroup group = new ButtonGroup();
    group.add(newFile);
    group.add(oldFile);
    addExtPan.setLayout(new BorderLayout());
    JButton addExt = new JButton(IconTheme.JabRefIcon.ADD.getIcon());
    addExtPan.add(addExt, BorderLayout.EAST);
    addExtPan.setToolTipText(Localization.lang("Add"));
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref",
            "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref");
    FormBuilder builder = FormBuilder.create().layout(layout);

    builder.addSeparator(Localization.lang("Built-in journal list")).xyw(2, 1, 6);
    JLabel description = new JLabel(
            "<HTML>" + Localization.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>"
                    + Localization.lang(
                            "You can add additional journal names by setting up a personal journal list,<br>as "
                                    + "well as linking to external journal lists.")
                    + "</HTML>");
    description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    builder.add(description).xyw(2, 2, 6);
    JButton viewBuiltin = new JButton(Localization.lang("View"));
    builder.add(viewBuiltin).xy(7, 2);
    builder.addSeparator(Localization.lang("Personal journal list")).xyw(2, 3, 6);

    builder.add(newFile).xy(3, 4);
    builder.add(newNameTf).xy(5, 4);
    JButton browseNew = new JButton(Localization.lang("Browse"));
    builder.add(browseNew).xy(7, 4);
    builder.add(oldFile).xy(3, 5);
    builder.add(personalFile).xy(5, 5);
    JButton browseOld = new JButton(Localization.lang("Browse"));
    builder.add(browseOld).xy(7, 5);

    userPanel.setLayout(new BorderLayout());
    builder.add(userPanel).xyw(2, 6, 4);
    ButtonStackBuilder butBul = new ButtonStackBuilder();
    butBul.addButton(add);
    butBul.addButton(remove);

    butBul.addGlue();
    builder.add(butBul.getPanel()).xy(7, 6);

    builder.addSeparator(Localization.lang("External files")).xyw(2, 8, 6);
    externalFilesPanel.setLayout(new BorderLayout());

    setLayout(new BorderLayout());
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(builder.getPanel(), BorderLayout.NORTH);
    add(externalFilesPanel, BorderLayout.CENTER);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton ok = new JButton(Localization.lang("OK"));
    bb.addButton(ok);
    JButton cancel = new JButton(Localization.lang("Cancel"));
    bb.addButton(cancel);
    bb.addUnrelatedGap();

    JButton help = new HelpAction(HelpFile.JOURNAL_ABBREV).getHelpButton();
    bb.addButton(help);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    dialog = new JDialog(frame, Localization.lang("Journal abbreviations"), false);
    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);

    // Set up panel for editing a single journal, to be used in a dialog box:
    FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "p, 2dlu, p");
    FormBuilder builder2 = FormBuilder.create().layout(layout2);
    builder2.add(Localization.lang("Journal name")).xy(1, 1);
    builder2.add(nameTf).xy(3, 1);
    builder2.add(Localization.lang("ISO abbreviation")).xy(1, 3);
    builder2.add(abbrTf).xy(3, 3);
    journalEditPanel = builder2.getPanel();

    viewBuiltin.addActionListener(e -> {
        JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader
                .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs))
                .getAbbreviations()));
        JScrollPane pane = new JScrollPane(table);
        JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"),
                JOptionPane.INFORMATION_MESSAGE);
    });

    browseNew.addActionListener(e -> {
        Path old = null;
        if (!newNameTf.getText().isEmpty()) {
            old = Paths.get(newNameTf.getText());
        }
        String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.SAVE_DIALOG, false);
        if (name != null) {
            newNameTf.setText(name);
            newFile.setSelected(true);
        }
    });

    browseOld.addActionListener(e -> {
        Path old = null;
        if (!personalFile.getText().isEmpty()) {
            old = Paths.get(personalFile.getText());
        }
        String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.OPEN_DIALOG, false);
        if (name != null) {
            personalFile.setText(name);
            oldFile.setSelected(true);
            oldFile.setEnabled(true);
            setupUserTable();
        }
    });

    ok.addActionListener(e -> {
        if (readyToClose()) {
            storeSettings();
            dialog.dispose();
        }
    });

    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };
    cancel.addActionListener(cancelAction);

    add.addActionListener(tableModel);
    remove.addActionListener(tableModel);
    addExt.addActionListener(e -> {
        externals.add(new ExternalFileEntry());
        buildExternalsPanel();
    });

    // Key bindings:
    ActionMap am = getActionMap();
    InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelAction);

    int xSize = getPreferredSize().width;
    dialog.setSize(xSize + 10, 700);
}

From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java

public static void main(String[] args) {
    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createLineBorder(Color.black, 2));
    JLabel label = new JLabel("Hello World");
    label.setIcon(UIManager.getIcon("FileView.computerIcon"));
    label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    content.add(label, BorderLayout.CENTER);

    final AnimatedWindow window = new AnimatedWindow(null);
    window.setFinalLocation(new Point(200, 200));
    window.setContentPane(content);//from w  w  w.j  av  a2  s . c  o  m

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));

    JButton button = new JButton("Bottom -> Top");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.BOTTOM_TO_TOP);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Top -> Bottom");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.TOP_TO_BOTTOM);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Fade");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.FADE);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    JFrame app = new JFrame("AnimatedWindow Demo");
    app.setContentPane(buttonPanel);
    app.pack();
    app.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    app.setVisible(true);
}

From source file:InputVerificationDemo.java

public InputVerificationDemo() {
    super(new BorderLayout());
    setUpFormats();/*from   w  ww.  j av  a  2  s.c om*/
    double payment = computePayment(DEFAULT_AMOUNT, DEFAULT_RATE, DEFAULT_PERIOD);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JTextField(moneyFormat.format(DEFAULT_AMOUNT), 10);
    amountField.setInputVerifier(verifier);

    rateField = new JTextField(percentFormat.format(DEFAULT_RATE), 10);
    rateField.setInputVerifier(verifier);

    numPeriodsField = new JTextField(decimalFormat.format(DEFAULT_PERIOD), 10);
    numPeriodsField.setInputVerifier(verifier);

    paymentField = new JTextField(paymentFormat.format(payment), 10);
    paymentField.setInputVerifier(verifier);
    paymentField.setEditable(false);
    //Remove this component from the focus cycle.
    paymentField.setFocusable(false);
    paymentField.setForeground(Color.red);

    //Register an action listener to handle Return.
    amountField.addActionListener(verifier);
    rateField.addActionListener(verifier);
    numPeriodsField.addActionListener(verifier);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

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

/**
 * Standard constructor: builds a panel for displaying/editing the
 * properties of the specified axis./*w  ww .  j av a  2  s  . co  m*/
 * 
 * @param axis
 *            the axis whose properties are to be displayed/edited in the
 *            panel.
 */
public DefaultAxisEditor(Axis axis) {
    this.labelFont = axis.getLabelFont();
    this.labelPaintSample = new PaintSample(axis.getLabelPaint());
    this.tickLabelFont = axis.getTickLabelFont();
    this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint());

    // Insets values
    this.tickLabelInsets = axis.getTickLabelInsets();
    this.labelInsets = axis.getLabelInsets();

    setLayout(new BorderLayout());

    JPanel general = new JPanel(new BorderLayout());
    general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("General")));

    JPanel interior = new JPanel(new LCBLayout(5));
    interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    interior.add(new JLabel(localizationResources.getString("Label")));
    this.label = new JTextField(axis.getLabel());
    interior.add(this.label);
    interior.add(new JPanel());

    interior.add(new JLabel(localizationResources.getString("Font")));
    this.labelFontField = new FontDisplayField(this.labelFont);
    interior.add(this.labelFontField);
    JButton b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelFont");
    b.addActionListener(this);
    interior.add(b);

    interior.add(new JLabel(localizationResources.getString("Paint")));
    interior.add(this.labelPaintSample);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectLabelPaint");
    b.addActionListener(this);
    interior.add(b);

    general.add(interior);

    add(general, BorderLayout.NORTH);

    this.slot1 = new JPanel(new BorderLayout());

    JPanel other = new JPanel(new BorderLayout());
    other.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            localizationResources.getString("Other")));

    this.otherTabs = new JTabbedPane();
    this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

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

    this.showTickLabelsCheckBox = new JCheckBox(localizationResources.getString("Show_tick_labels"),
            axis.isTickLabelsVisible());
    ticks.add(this.showTickLabelsCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    ticks.add(new JLabel(localizationResources.getString("Tick_label_font")));
    this.tickLabelFontField = new FontDisplayField(this.tickLabelFont);
    ticks.add(this.tickLabelFontField);
    b = new JButton(localizationResources.getString("Select..."));
    b.setActionCommand("SelectTickLabelFont");
    b.addActionListener(this);
    ticks.add(b);

    this.showTickMarksCheckBox = new JCheckBox(localizationResources.getString("Show_tick_marks"),
            axis.isTickMarksVisible());
    ticks.add(this.showTickMarksCheckBox);
    ticks.add(new JPanel());
    ticks.add(new JPanel());

    this.otherTabs.add(localizationResources.getString("Ticks"), ticks);

    other.add(this.otherTabs);

    this.slot1.add(other);

    this.slot2 = new JPanel(new BorderLayout());
    this.slot2.add(this.slot1, BorderLayout.NORTH);
    add(this.slot2);

}

From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java

/**
 * Puts together the GUI main panel component.
 * /*  w  w w.  j a v  a 2  s.  c  om*/
 * @return
 */
protected JPanel buildMainPanel() {

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel.add(buildMeasureCountSubPanel());
    panel.add(buildFileSelectionSubPanel());
    panel.add(buildActionButtonSubPanel());

    return panel;
}

From source file:net.sf.jabref.gui.preftabs.PreferencesDialog.java

public PreferencesDialog(JabRefFrame parent) {
    super(parent, Localization.lang("JabRef preferences"), false);
    JabRefPreferences prefs = JabRefPreferences.getInstance();
    frame = parent;/*from   w  ww.j  ava  2 s .  co  m*/

    main = new JPanel();
    JPanel mainPanel = new JPanel();
    JPanel lower = new JPanel();

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(lower, BorderLayout.SOUTH);

    final CardLayout cardLayout = new CardLayout();
    main.setLayout(cardLayout);

    List<PrefsTab> tabs = new ArrayList<>();
    tabs.add(new GeneralTab(prefs));
    tabs.add(new NetworkTab(prefs));
    tabs.add(new FileTab(frame, prefs));
    tabs.add(new FileSortTab(prefs));
    tabs.add(new EntryEditorPrefsTab(frame, prefs));
    tabs.add(new GroupsPrefsTab(prefs));
    tabs.add(new AppearancePrefsTab(prefs));
    tabs.add(new ExternalTab(frame, this, prefs));
    tabs.add(new TablePrefsTab(prefs));
    tabs.add(new TableColumnsTab(prefs, parent));
    tabs.add(new LabelPatternPrefTab(prefs, parent.getCurrentBasePanel()));
    tabs.add(new PreviewPrefsTab(prefs));
    tabs.add(new NameFormatterTab(prefs));
    tabs.add(new ImportSettingsTab(prefs));
    tabs.add(new XmpPrefsTab(prefs));
    tabs.add(new AdvancedTab(prefs));

    // add all tabs
    tabs.forEach(tab -> main.add((Component) tab, tab.getTabName()));

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    String[] tabNames = tabs.stream().map(PrefsTab::getTabName).toArray(String[]::new);
    JList<String> chooser = new JList<>(tabNames);
    chooser.setBorder(BorderFactory.createEtchedBorder());
    // Set a prototype value to control the width of the list:
    chooser.setPrototypeCellValue("This should be wide enough");
    chooser.setSelectedIndex(0);
    chooser.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Add the selection listener that will show the correct panel when
    // selection changes:
    chooser.addListSelectionListener(e -> {
        if (e.getValueIsAdjusting()) {
            return;
        }
        String o = chooser.getSelectedValue();
        cardLayout.show(main, o);
    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new GridLayout(4, 1));
    buttons.add(importPreferences, 0);
    buttons.add(exportPreferences, 1);
    buttons.add(showPreferences, 2);
    buttons.add(resetPreferences, 3);

    JPanel westPanel = new JPanel();
    westPanel.setLayout(new BorderLayout());
    westPanel.add(chooser, BorderLayout.CENTER);
    westPanel.add(buttons, BorderLayout.SOUTH);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(main, BorderLayout.CENTER);
    mainPanel.add(westPanel, BorderLayout.WEST);

    JButton ok = new JButton(Localization.lang("OK"));
    JButton cancel = new JButton(Localization.lang("Cancel"));
    ok.addActionListener(new OkAction());
    CancelAction cancelAction = new CancelAction();
    cancel.addActionListener(cancelAction);
    lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(lower);
    buttonBarBuilder.addGlue();
    buttonBarBuilder.addButton(ok);
    buttonBarBuilder.addButton(cancel);
    buttonBarBuilder.addGlue();

    // Key bindings:
    KeyBinder.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction);

    // Import and export actions:
    exportPreferences.setToolTipText(Localization.lang("Export preferences to file"));
    exportPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.SAVE_DIALOG, false);
        if (filename == null) {
            return;
        }
        File file = new File(filename);
        if (!file.exists() || (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("'%0' exists. Overwrite file?", file.getName()),
                Localization.lang("Export preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) {

            try {
                prefs.exportPreferences(filename);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    importPreferences.setToolTipText(Localization.lang("Import preferences from file"));
    importPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.OPEN_DIALOG, false);
        if (filename != null) {
            try {
                prefs.importPreferences(filename);
                updateAfterPreferenceChanges();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Import preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Import preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    showPreferences.addActionListener(
            e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame)
                    .setVisible(true));
    resetPreferences.addActionListener(e -> {
        if (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("Are you sure you want to reset all settings to default values?"),
                Localization.lang("Reset preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
            try {
                prefs.clear();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Reset preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (BackingStoreException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Reset preferences"), JOptionPane.ERROR_MESSAGE);
            }
            updateAfterPreferenceChanges();
        }
    });

    setValues();

    pack();

}

From source file:InputVerificationDialogDemo.java

public InputVerificationDialogDemo() {
    super(new BorderLayout());
    setUpFormats();//  www. j  a  v  a2s.  c om
    double payment = computePayment(DEFAULT_AMOUNT, DEFAULT_RATE, DEFAULT_PERIOD);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JTextField(moneyFormat.format(DEFAULT_AMOUNT), 10);
    amountField.setInputVerifier(verifier);

    rateField = new JTextField(percentFormat.format(DEFAULT_RATE), 10);
    rateField.setInputVerifier(verifier);

    numPeriodsField = new JTextField(decimalFormat.format(DEFAULT_PERIOD), 10);
    numPeriodsField.setInputVerifier(verifier);

    paymentField = new JTextField(paymentFormat.format(payment), 10);
    paymentField.setInputVerifier(verifier);
    paymentField.setEditable(false);
    //Remove this component from the focus cycle.
    paymentField.setFocusable(false);
    paymentField.setForeground(Color.red);

    //Register an action listener to handle Return.
    amountField.addActionListener(verifier);
    rateField.addActionListener(verifier);
    numPeriodsField.addActionListener(verifier);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createECGData(long timeZone) {
    ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1));
    dateAxises = new DateAxis[LEAD_COUNT];
    ECGSeries = new TimeSeries[LEAD_COUNT * 2];
    for (int i = 0; i < LEAD_COUNT; i++) {
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset  TimeSeriesCollection
        ECGSeries[i] = new TimeSeries("?" + (i + 1));
        ECGSeries[i].setMaximumItemCount(500);
        ECGSeries[i + LEAD_COUNT] = new TimeSeries("");
        ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone);
        ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2);

        timeseriescollection.addSeries(ECGSeries[i]);
        timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]);

        //DateAxis dateaxis = new DateAxis("Time");
        dateAxises[i] = new DateAxis("");
        dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        dateAxises[i].setTickLabelsVisible(true);
        dateAxises[i].setVisible(false);

        //NumberAxis numberaxis = new NumberAxis("ecg");
        NumberAxis numberaxis = new NumberAxis("ecg");
        numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        numberaxis.setVisible(false);/*w  w w  .j a va 2s . c  o m*/
        numberaxis.setLowerBound(1500D);
        numberaxis.setUpperBound(3000D);

        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
        xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
        xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2));
        xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
        xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

        XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer);
        xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
        xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
        xyplot.setBackgroundPaint(Color.BLACK);

        JFreeChart jfreechart = new JFreeChart(xyplot);
        jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
        jfreechart.getLegend().setVisible(false);

        ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100),
                0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

        chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
                , BorderFactory.createEmptyBorder() //????
        ));
        chartpanel.setMouseZoomable(false); //?
        ECGData.add(chartpanel);
    }
}

From source file:com.haskins.cloudtrailviewer.sidebar.EventsStats.java

private void addTable() {

    defaultTableModel.addColumn("");
    defaultTableModel.addColumn("Property");
    defaultTableModel.addColumn("Value");

    final LegendColourRenderer cellRenderer = new LegendColourRenderer();
    final JTable table = new JTable(defaultTableModel) {

        @Override//from   w  w w.j  av  a2s .com
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == 0) {
                return cellRenderer;
            }
            return super.getCellRenderer(row, column);
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        };
    };

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {

            if (e.getFirstIndex() >= 0) {

                String value = (String) defaultTableModel.getValueAt(table.getSelectedRow(), 1);
                eventTablePanel.setFilterString(value);
            }
        }
    });

    TableColumn column;
    for (int i = 0; i < 3; i++) {
        column = table.getColumnModel().getColumn(i);

        switch (i) {
        case 0:
            column.setMinWidth(15);
            column.setMaxWidth(15);
            column.setPreferredWidth(15);
            break;

        case 2:
            column.setMinWidth(70);
            column.setMaxWidth(70);
            column.setPreferredWidth(70);
            break;
        }
    }

    JScrollPane tablecrollPane = new JScrollPane(table);
    tablecrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    this.add(tablecrollPane, BorderLayout.CENTER);
}

From source file:net.sf.mzmine.util.dialogs.AxesSetupDialog.java

/**
 * Constructor/*from   w w w .j a v a2  s . c o  m*/
 */
public AxesSetupDialog(XYPlot plot) {

    // Make dialog modal
    super(MZmineCore.getDesktop().getMainWindow(), true);

    xAxis = plot.getDomainAxis();
    yAxis = plot.getRangeAxis();

    NumberFormat defaultFormatter = NumberFormat.getNumberInstance();
    NumberFormat xAxisFormatter = defaultFormatter;
    if (xAxis instanceof NumberAxis)
        xAxisFormatter = ((NumberAxis) xAxis).getNumberFormatOverride();
    NumberFormat yAxisFormatter = defaultFormatter;
    if (yAxis instanceof NumberAxis)
        yAxisFormatter = ((NumberAxis) yAxis).getNumberFormatOverride();

    // Create labels and fields
    JLabel lblXTitle = new JLabel(xAxis.getLabel());
    JLabel lblXAutoRange = new JLabel("Auto range");
    JLabel lblXMin = new JLabel("Minimum");
    JLabel lblXMax = new JLabel("Maximum");
    JLabel lblXAutoTick = new JLabel("Auto tick size");
    JLabel lblXTick = new JLabel("Tick size");

    JLabel lblYTitle = new JLabel(yAxis.getLabel());
    JLabel lblYAutoRange = new JLabel("Auto range");
    JLabel lblYMin = new JLabel("Minimum");
    JLabel lblYMax = new JLabel("Maximum");
    JLabel lblYAutoTick = new JLabel("Auto tick size");
    JLabel lblYTick = new JLabel("Tick size");

    checkXAutoRange = new JCheckBox();
    checkXAutoRange.addActionListener(this);
    checkXAutoTick = new JCheckBox();
    checkXAutoTick.addActionListener(this);
    fieldXMin = new JFormattedTextField(xAxisFormatter);
    fieldXMax = new JFormattedTextField(xAxisFormatter);
    fieldXTick = new JFormattedTextField(xAxisFormatter);

    checkYAutoRange = new JCheckBox();
    checkYAutoRange.addActionListener(this);
    checkYAutoTick = new JCheckBox();
    checkYAutoTick.addActionListener(this);
    fieldYMin = new JFormattedTextField(yAxisFormatter);
    fieldYMax = new JFormattedTextField(yAxisFormatter);
    fieldYTick = new JFormattedTextField(yAxisFormatter);

    // Create a panel for labels and fields
    JPanel pnlLabelsAndFields = new JPanel(new GridLayout(0, 2));

    pnlLabelsAndFields.add(lblXTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblXAutoRange);
    pnlLabelsAndFields.add(checkXAutoRange);
    pnlLabelsAndFields.add(lblXMin);
    pnlLabelsAndFields.add(fieldXMin);
    pnlLabelsAndFields.add(lblXMax);
    pnlLabelsAndFields.add(fieldXMax);
    if (xAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblXAutoTick);
        pnlLabelsAndFields.add(checkXAutoTick);
        pnlLabelsAndFields.add(lblXTick);
        pnlLabelsAndFields.add(fieldXTick);
    }

    // Empty row
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(new JPanel());

    pnlLabelsAndFields.add(lblYTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblYAutoRange);
    pnlLabelsAndFields.add(checkYAutoRange);
    pnlLabelsAndFields.add(lblYMin);
    pnlLabelsAndFields.add(fieldYMin);
    pnlLabelsAndFields.add(lblYMax);
    pnlLabelsAndFields.add(fieldYMax);
    if (yAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblYAutoTick);
        pnlLabelsAndFields.add(checkYAutoTick);
        pnlLabelsAndFields.add(lblYTick);
        pnlLabelsAndFields.add(fieldYTick);
    }

    // Create buttons
    JPanel pnlButtons = new JPanel();
    btnOK = new JButton("OK");
    btnOK.addActionListener(this);
    btnApply = new JButton("Apply");
    btnApply.addActionListener(this);
    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(this);

    pnlButtons.add(btnOK);
    pnlButtons.add(btnApply);
    pnlButtons.add(btnCancel);

    // Put everything into a main panel
    JPanel pnlAll = new JPanel(new BorderLayout());
    pnlAll.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(pnlAll);

    pnlAll.add(pnlLabelsAndFields, BorderLayout.CENTER);
    pnlAll.add(pnlButtons, BorderLayout.SOUTH);

    pack();

    setTitle("Please set ranges for axes");
    setResizable(false);
    setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

    getValuesToControls();

}