Example usage for javax.swing BorderFactory createEmptyBorder

List of usage examples for javax.swing BorderFactory createEmptyBorder

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:components.ProgressBarDemo2.java

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

    //Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);//  w w w. java2s . c  o m

    //Call setStringPainted now so that the progress bar height
    //stays the same whether or not the string is shown.
    progressBar.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);
    panel.add(progressBar);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:BRHInit.java

public void showLoginPrompt() {
    if (login_window == null) {
        login_window = new JFrame("BRH Console");
        login_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel top_panel = new JPanel();
        login_window.getContentPane().add(top_panel);

        top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS));
        top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        JPanel p = new JPanel();
        top_panel.add(p);//from www .j a va  2s. com
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        JPanel col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(new JLabel("email"));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(new JLabel("password"));

        p.add(Box.createRigidArea(new Dimension(5, 0)));

        col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(email = new JTextField(20));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(password = new JPasswordField());

        if (email_arg != null)
            email.setText(email_arg);
        if (password_arg != null)
            password.setText(password_arg);

        top_panel.add(Box.createRigidArea(new Dimension(0, 10)));

        p = new JPanel();
        top_panel.add(p);
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        p.add(Box.createHorizontalGlue());
        p.add(login_ok = new JButton("OK"));
        p.add(Box.createRigidArea(new Dimension(5, 0)));
        p.add(login_cancel = new JButton("Cancel"));
        p.add(Box.createHorizontalGlue());

        login_ok.addActionListener(this);
        login_cancel.addActionListener(this);

        login_window.pack();
    }

    cookie = null;
    login_window.setVisible(true);
}

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

private void init() {
    Border border = BorderFactory.createBevelBorder(BevelBorder.RAISED);
    JPanel topPanel = new JPanel();

    topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    topPanel.setLayout(new GridLayout(1, 2));

    infoLabel1.setText("Message Renderers");

    setLayout(new BorderLayout());
    setBorder(BorderFactory.createTitledBorder(border, "Renderers"));

    topPanel.add(infoLabel1);//from w ww. j  a v  a  2  s .c  o  m
    topSP.setViewportView(classTable);

    classTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    add(topPanel, BorderLayout.NORTH);
    add(splitPane, BorderLayout.CENTER);

    splitPane.add(topSP, "top");
    splitPane.add(bottomSP, "bottom");
    splitPane.setDividerLocation(200);

    // splitPane.setShowGripper(true) ;

    classTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            doRendererSelected(e);
        }
    });

}

From source file:net.sf.jabref.gui.openoffice.CitationManager.java

public CitationManager(final JabRefFrame frame, OOBibBase ooBase)
        throws NoSuchElementException, WrappedTargetException, UnknownPropertyException {
    diag = new JDialog(frame, Localization.lang("Manage citations"), true);
    this.ooBase = ooBase;

    list = new BasicEventList<>();
    XNameAccess nameAccess = ooBase.getReferenceMarks();
    List<String> names = ooBase.getJabRefReferenceMarks(nameAccess);
    for (String name : names) {
        list.add(new CitationEntry(name,
                "<html>..." + ooBase.getCitationContext(nameAccess, name, 30, 30, true) + "...</html>",
                ooBase.getCustomProperty(name)));
    }/*from  ww w  . j  av  a  2  s.c o m*/
    tableModel = new DefaultEventTableModel<>(list, new CitationEntryFormat());
    table = new JTable(tableModel);
    diag.add(new JScrollPane(table), 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.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);

    diag.pack();
    diag.setSize(700, 400);

    ok.addActionListener(e -> {
        try {
            storeSettings();
        } catch (UnknownPropertyException | NotRemoveableException | PropertyExistException
                | IllegalTypeException | IllegalArgumentException ex) {
            LOGGER.warn("Problem modifying citation", ex);
            JOptionPane.showMessageDialog(frame, Localization.lang("Problem modifying citation"));
        }
        diag.dispose();
    });

    Action cancelAction = new AbstractAction() {

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

    bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    bb.getPanel().getActionMap().put("close", cancelAction);

    table.getColumnModel().getColumn(0).setPreferredWidth(580);
    table.getColumnModel().getColumn(1).setPreferredWidth(110);
    table.setPreferredScrollableViewportSize(new Dimension(700, 500));
    table.addMouseListener(new TableClickListener());
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.DefItemEditorPlugin.java

protected void edit() {
    int maxCols = 0;
    if (!isRow) {
        for (FormRowIFace row : formViewDef.getRows()) {
            maxCols = Math.max(row.getCells().size(), maxCols);
        }/*from  w ww.j  a  va 2s. co  m*/
    }

    item = isRow ? formViewDef.getRowDefItem() : formViewDef.getColumnDefItem();

    DefItemEditorPanel panel = new DefItemEditorPanel(item,
            isRow ? formViewDef.getRows().size() * 2 : maxCols * 2, true);

    panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(),
            (isRow ? "Row" : "Column") + " Definition Editor", true, panel);
    dlg.setVisible(true);

    if (!dlg.isCancelled()) {
        panel.getDataFromUI();
        defStr = isRow ? formViewDef.getRowDef() : formViewDef.getColumnDef();
        label.setText(defStr);
    }
}

From source file:DialogDemo.java

/** Creates the GUI shown inside the frame's content pane. */
public DialogDemo(JFrame frame) {
    super(new BorderLayout());
    this.frame = frame;
    customDialog = new CustomDialog(frame, "geisel", this);
    customDialog.pack();//from  w ww.j av a  2s  .  c om

    // Create the components.
    JPanel frequentPanel = createSimpleDialogBox();
    JPanel featurePanel = createFeatureDialogBox();
    JPanel iconPanel = createIconDialogBox();
    label = new JLabel("Click the \"Show it!\" button" + " to bring up the selected dialog.", JLabel.CENTER);

    // Lay them out.
    Border padding = BorderFactory.createEmptyBorder(20, 20, 5, 20);
    frequentPanel.setBorder(padding);
    featurePanel.setBorder(padding);
    iconPanel.setBorder(padding);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple Modal Dialogs", null, frequentPanel, simpleDialogDesc); // tooltip text
    tabbedPane.addTab("More Dialogs", null, featurePanel, moreDialogDesc); // tooltip
                                                                           // text
    tabbedPane.addTab("Dialog Icons", null, iconPanel, iconDesc); // tooltip
                                                                  // text

    add(tabbedPane, BorderLayout.CENTER);
    add(label, BorderLayout.PAGE_END);
    label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}

From source file:edu.ku.brc.af.ui.forms.RecordSetTableViewObj.java

protected void initMainComp() {

    mainComp = new RestrictablePanel();
    mainComp.setLayout(new BorderLayout());
    if (mvParent == null) {
        mainComp.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    }/*  ww w  .jav a2 s  .  c o m*/

    /*
    PanelBuilder builder = new PanelBuilder(new FormLayout("f:1px:g,p,1px,p,1px,p,1px,p,1px,p", "p"));
    CellConstraints cc  = new CellConstraints();
            
    builder.add(editButton, cc.xy(2,1));
    builder.add(newButton, cc.xy(4,1));
    builder.add(deleteButton, cc.xy(6,1));
    builder.add(validationInfoBtn, cc.xy(8,1));
    builder.add(switcherUI, cc.xy(10,1));
    southPanel = builder.getPanel();
    */
    //mainComp.add(formPane,BorderLayout.CENTER);
    mainComp.add(southPanel, BorderLayout.SOUTH);
}

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

/**
 * Overridden!/*from  ww w  . j a  v  a 2  s . c  o  m*/
 * 
 * @see de.tbuchloh.kiskis.gui.dialogs.KisKisDialog#createMainPanel()
 */
@Override
protected Component createMainPanel() {
    final SimpleInternalFrame settings = createSettingsPanel();

    final JPanel root = new JPanel(new BorderLayout());
    root.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    root.add(settings, BorderLayout.NORTH);
    final SimpleInternalFrame note = createNotePanel();
    root.add(note, BorderLayout.SOUTH);

    return root;
}

From source file:components.ScrollDemo.java

public ScrollDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    //Get the image to use.
    ImageIcon bee = createImageIcon("images/flyingBee.jpg");

    //Create the row and column headers.
    columnView = new Rule(Rule.HORIZONTAL, true);
    rowView = new Rule(Rule.VERTICAL, true);

    if (bee != null) {
        columnView.setPreferredWidth(bee.getIconWidth());
        rowView.setPreferredHeight(bee.getIconHeight());
    } else {//w w w . j  ava 2  s.c  o m
        columnView.setPreferredWidth(320);
        rowView.setPreferredHeight(480);
    }

    //Create the corners.
    JPanel buttonCorner = new JPanel(); //use FlowLayout
    isMetric = new JToggleButton("cm", true);
    isMetric.setFont(new Font("SansSerif", Font.PLAIN, 11));
    isMetric.setMargin(new Insets(2, 2, 2, 2));
    isMetric.addItemListener(this);
    buttonCorner.add(isMetric);

    //Set up the scroll pane.
    picture = new ScrollablePicture(bee, columnView.getIncrement());
    JScrollPane pictureScrollPane = new JScrollPane(picture);
    pictureScrollPane.setPreferredSize(new Dimension(300, 250));
    pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

    pictureScrollPane.setColumnHeaderView(columnView);
    pictureScrollPane.setRowHeaderView(rowView);

    //Set the corners.
    //In theory, to support internationalization you would change
    //UPPER_LEFT_CORNER to UPPER_LEADING_CORNER,
    //LOWER_LEFT_CORNER to LOWER_LEADING_CORNER, and
    //UPPER_RIGHT_CORNER to UPPER_TRAILING_CORNER.  In practice,
    //bug #4467063 makes that impossible (in 1.4, at least).
    pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner);
    pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, new Corner());
    pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new Corner());

    //Put it in this panel.
    add(pictureScrollPane);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:com.floreantpos.ui.dialog.DiscountSelectionDialog.java

private void initComponent() {
    setOkButtonText(POSConstants.SAVE_BUTTON_TEXT);
    createCouponSearchPanel();/*from   w  w w. ja va2  s  . com*/
    getContentPanel().add(itemSearchPanel, BorderLayout.NORTH);

    buttonsPanel = new ScrollableFlowPanel(FlowLayout.LEADING);

    JScrollPane scrollPane = new PosScrollPane(buttonsPanel, PosScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            PosScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(80, 0));
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
            scrollPane.getBorder()));

    getContentPanel().add(scrollPane, BorderLayout.CENTER);

    rendererDiscounts();

    setSize(1024, 720);
}