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.k42b3.sacmis.Sacmis.java

public Sacmis(String path, String file, int exitCode, boolean writerStdIn) throws Exception {
    this.path = path;
    this.file = file;
    this.exitCode = exitCode;
    this.writerStdIn = writerStdIn;

    this.setTitle("sacmis (version: " + ver + ")");

    this.setLocation(100, 100);

    this.setSize(600, 500);

    this.setMinimumSize(this.getSize());

    // arguments//  ww w .ja va2 s.  co m
    JPanel panelArgs = new JPanel();

    panelArgs.setLayout(new BorderLayout());

    panelArgs.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    this.args = new Args();

    this.args.setText(file);

    panelArgs.add(this.args, BorderLayout.CENTER);

    this.add(panelArgs, BorderLayout.NORTH);

    // main panel
    JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    this.in = new In();

    JScrollPane scrIn = new JScrollPane(this.in);

    scrIn.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    scrIn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    scrIn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.add(scrIn);

    this.out = new Out();

    JScrollPane scrOut = new JScrollPane(this.out);

    scrOut.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    scrOut.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    scrOut.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.add(scrOut);

    this.add(sp, BorderLayout.CENTER);

    // toolbar
    this.toolbar = new Toolbar();

    this.toolbar.getRun().addActionListener(new runHandler());
    this.toolbar.getReset().addActionListener(new resetHandler());
    this.toolbar.getAbout().addActionListener(new aboutHandler());
    this.toolbar.getExit().addActionListener(new exitHandler());

    this.getContentPane().add(this.toolbar, BorderLayout.SOUTH);

    this.setVisible(true);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.loadFile();
}

From source file:org.jdal.swing.ApplicationContextGuiFactory.java

/**
 * //from  ww  w. ja  va 2  s. c  o  m
 * @param name title string
 * @return a new titled border
 * @deprecated use FormUtils.createTitledBorder instead.
 */
@Deprecated
public static Border createTitledBorder(String name) {
    Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
    Border title = BorderFactory.createTitledBorder(name);

    return BorderFactory.createCompoundBorder(title, margin);
}

From source file:FocusEventDemo.java

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

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0; //Make column as wide as possible.
    JTextField textField = new JTextField("A TextField");
    textField.setMargin(new Insets(0, 2, 0, 2));
    textField.addFocusListener(this);
    gridbag.setConstraints(textField, c);
    add(textField);//ww w .  jav  a2  s  .c  o  m

    c.weightx = 0.1; //Widen every other column a bit, when possible.
    c.fill = GridBagConstraints.NONE;
    JLabel label = new JLabel("A Label");
    label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    label.addFocusListener(this);
    gridbag.setConstraints(label, c);
    add(label);

    String comboPrefix = "ComboBox Item #";
    final int numItems = 15;
    Vector vector = new Vector(numItems);
    for (int i = 0; i < numItems; i++) {
        vector.addElement(comboPrefix + i);
    }
    JComboBox comboBox = new JComboBox(vector);
    comboBox.addFocusListener(this);
    gridbag.setConstraints(comboBox, c);
    add(comboBox);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JButton button = new JButton("A Button");
    button.addFocusListener(this);
    gridbag.setConstraints(button, c);
    add(button);

    c.weightx = 0.0;
    c.weighty = 0.1;
    c.fill = GridBagConstraints.BOTH;
    String listPrefix = "List Item #";
    Vector listVector = new Vector(numItems);
    for (int i = 0; i < numItems; i++) {
        listVector.addElement(listPrefix + i);
    }
    JList list = new JList(listVector);
    list.setSelectedIndex(1); //It's easier to see the focus change
    //if an item is selected.
    list.addFocusListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);
    //We want to prevent the list's scroll bars
    //from getting the focus - even with the keyboard.
    //Note that in general we prefer setRequestFocusable
    //over setFocusable for reasons of accessibility,
    //but this is to work around bug #4866958.
    listScrollPane.getVerticalScrollBar().setFocusable(false);
    listScrollPane.getHorizontalScrollBar().setFocusable(false);
    gridbag.setConstraints(listScrollPane, c);
    add(listScrollPane);

    c.weighty = 1.0; //Make this row as tall as possible.
    c.gridheight = GridBagConstraints.REMAINDER;
    //Set up the area that reports focus-gained and focus-lost events.
    display = new JTextArea();
    display.setEditable(false);
    //The method setRequestFocusEnabled prevents a
    //component from being clickable, but it can still
    //get the focus through the keyboard - this ensures
    //user accessibility.
    display.setRequestFocusEnabled(false);
    display.addFocusListener(this);
    JScrollPane displayScrollPane = new JScrollPane(display);

    //Work around for bug #4866958.
    displayScrollPane.getHorizontalScrollBar().setFocusable(false);
    displayScrollPane.getVerticalScrollBar().setFocusable(false);
    gridbag.setConstraints(displayScrollPane, c);
    add(displayScrollPane);

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

From source file:MainClass.java

public MainClass() {
    super();/*  w  w  w.j a  va 2 s .  c  om*/

    setChannel(currentNumber);

    numberLabel.setHorizontalAlignment(JLabel.CENTER);
    numberLabel.setFont(new Font("Serif", Font.PLAIN, 32));

    getContentPane().add(numberLabel, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16));
    getContentPane().add(buttonPanel, BorderLayout.CENTER);
    buttonPanel.add(new JButton(upAction));
    buttonPanel.add(new JButton(gotoFavoriteAction));
    buttonPanel.add(new JButton(downAction));
    buttonPanel.add(new JButton(setFavoriteAction));

    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("Number");
    menu.add(new JMenuItem(upAction));
    menu.add(new JMenuItem(downAction));
    menu.addSeparator();
    menu.add(new JMenuItem(gotoFavoriteAction));
    menu.add(new JMenuItem(setFavoriteAction));
    mb.add(menu);
    setJMenuBar(mb);
}

From source file:FocusConceptsDemo.java

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

    b1 = new JButton("JButton");
    b2 = new JButton("JButton");
    b3 = new JButton("JButton");
    b4 = new JButton("JButton");
    JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.add(b1);/*from   w ww  .  j  av  a2s.c o  m*/
    buttonPanel.add(b2);
    buttonPanel.add(b3);
    buttonPanel.add(b4);

    text1 = new JTextArea("JTextArea", 15, 40);
    JPanel textAreaPanel = new JPanel(new BorderLayout());
    textAreaPanel.add(text1, BorderLayout.CENTER);

    t1 = new JTextField("JTextField");
    t2 = new JTextField("JTextField");
    t3 = new JTextField("JTextField");
    t4 = new JTextField("JTextField");
    JPanel textFieldPanel = new JPanel(new GridLayout(1, 1));
    textFieldPanel.add(t1);
    textFieldPanel.add(t2);
    textFieldPanel.add(t3);
    textFieldPanel.add(t4);

    add(buttonPanel, BorderLayout.PAGE_START);
    add(textAreaPanel, BorderLayout.CENTER);
    add(textFieldPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:org.jfree.chart.demo.MemoryUsageDemo.java

public MemoryUsageDemo(int i) {
    super(new BorderLayout());
    total = new TimeSeries("Total Memory");
    total.setMaximumItemAge(i);//from   w  ww. j ava  2  s  .  c  o m
    free = new TimeSeries("Free Memory");
    free.setMaximumItemAge(i);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(total);
    timeseriescollection.addSeries(free);
    DateAxis dateaxis = new DateAxis("Time");
    NumberAxis numberaxis = new NumberAxis("Memory");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesPaint(1, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
    jfreechart.setBackgroundPaint(Color.white);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartpanel);
}

From source file:gui.TraitViewerDialog.java

private JPanel createButtons() {
    bClose = new JButton("Close");
    bClose.addActionListener(this);

    JPanel p1 = new JPanel(new GridLayout(1, 1, 5, 5));
    p1.add(bClose);/*from  w  w w. j  a  va2 s .c  o  m*/

    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    p2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    p2.add(p1);

    return p2;
}

From source file:mergedoc.ui.MergeDocFrame.java

/**
 * ??????/*from   ww  w .ja v a2  s.  c o  m*/
 * @throws MergeDocException ?????
 */
private void initComponent() throws MergeDocException {

    // ????
    preferencePanel = new PreferencePanel();
    mergeManager = new MergeManager();

    // ???
    mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.add(preferencePanel);

    // ??????
    JPanel outerPanel = new JPanel();
    outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
    outerPanel.add(mainPanel);
    outerPanel.add(ComponentFactory.createSpacer(0, 7));
    outerPanel.add(buttonBar);
    getContentPane().add(outerPanel);

    // ?
    initListener();
    buttonBar.setState(buttonBar.INIT_STATE);

    // 
    ConfigManager config = ConfigManager.getInstance();
    String iconPath = config.getFile("icon.png").toString();
    Image icon = Toolkit.getDefaultToolkit().createImage(iconPath);
    setIconImage(icon);

    // 
    setTitle(SETTING_TITLE);
    Persister psst = Persister.getInstance();
    setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0));
    setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570));
    int state = psst.getInt(Persister.WINDOW_STATE, NORMAL);
    if ((state & Frame.ICONIFIED) != ICONIFIED) {
        setExtendedState(state);
    }
    setVisible(true);
}

From source file:TreeExpandEventDemo2.java

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

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;/*w  ww  . jav a2s . c  o  m*/
    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:edu.ku.brc.specify.utilapps.ERDTable.java

public ERDTable(final DBTableInfo table) {
    super(new BorderLayout());
    this.table = table;

    if (ERDVisualizer.isDoShadow()) {
        setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    }/* w w  w .j a v a 2  s.  c o m*/
}