List of usage examples for javax.swing.border EmptyBorder EmptyBorder
public EmptyBorder(int top, int left, int bottom, int right)
From source file:BoxLayoutPane.java
public BoxLayoutPane() { // Use a BorderLayout layout manager to arrange various Box components this.setLayout(new BorderLayout()); // Give the entire panel a margin by adding an empty border // We could also do this by overriding getInsets() this.setBorder(new EmptyBorder(10, 10, 10, 10)); // Add a plain row of buttons along the top of the pane Box row = Box.createHorizontalBox(); for (int i = 0; i < 4; i++) { JButton b = new JButton("B" + i); b.setFont(new Font("serif", Font.BOLD, 12 + i * 2)); row.add(b);// www . j ava 2 s. co m } this.add(row, BorderLayout.NORTH); // Add a plain column of buttons along the right edge // Use BoxLayout with a different kind of Swing container // Give the column a border: can't do this with the Box class JPanel col = new JPanel(); col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS)); col.setBorder(new TitledBorder(new EtchedBorder(), "Column")); for (int i = 0; i < 4; i++) { JButton b = new JButton("Button " + i); b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2)); col.add(b); } this.add(col, BorderLayout.EAST); // Add column to right of panel // Add a button box along the bottom of the panel. // Use "Glue" to space the buttons evenly Box buttonbox = Box.createHorizontalBox(); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Okay")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Cancel")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Help")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space this.add(buttonbox, BorderLayout.SOUTH); // Create a component to display in the center of the panel JTextArea textarea = new JTextArea(); textarea.setText("This component has 12-pixel margins on left and top" + " and has 72-pixel margins on right and bottom."); textarea.setLineWrap(true); textarea.setWrapStyleWord(true); // Use Box objects to give the JTextArea an unusual spacing // First, create a column with 3 kids. The first and last kids // are rigid spaces. The middle kid is the text area Box fixedcol = Box.createVerticalBox(); fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels fixedcol.add(textarea); // Component fills in the rest fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels // Now create a row. Give it rigid spaces on the left and right, // and put the column from above in the middle. Box fixedrow = Box.createHorizontalBox(); fixedrow.add(Box.createHorizontalStrut(12)); fixedrow.add(fixedcol); fixedrow.add(Box.createHorizontalStrut(72)); // Now add the JTextArea in the column in the row to the panel this.add(fixedrow, BorderLayout.CENTER); }
From source file:Main.java
public ConfirmDialog(Frame parent) { super(parent, true); JPanel gui = new JPanel(new BorderLayout(3, 3)); gui.setBorder(new EmptyBorder(5, 5, 5, 5)); content = new JPanel(new BorderLayout()); gui.add(content, BorderLayout.CENTER); JPanel buttons = new JPanel(new FlowLayout(4)); gui.add(buttons, BorderLayout.SOUTH); JButton ok = new JButton("OK"); buttons.add(ok);//from w w w . j a va 2 s .co m ok.addActionListener(e -> { result = OK_OPTION; setVisible(false); }); JButton cancel = new JButton("Cancel"); buttons.add(cancel); cancel.addActionListener(e -> { result = CANCEL_OPTION; setVisible(false); }); setContentPane(gui); }
From source file:ListInput.java
public ListInput(String title, int numCols) { setLayout(null);//from w ww. ja v a 2 s .c o m setBorder(new EmptyBorder(5, 5, 5, 5)); label = new ListInputLabel(title, JLabel.LEFT); add(label); textfield = new ListInputText(numCols); textfield.addActionListener(this); label.setLabelFor(textfield); // NEW add(textfield); list = new ListInputList(); list.setVisibleRowCount(4); list.addListSelectionListener(this); scrollPane = new JScrollPane(list); add(scrollPane); }
From source file:org.martus.client.swingui.dialogs.UiChartPreviewDlg.java
private JComponent createScrollablePreview(JFreeChart chart) { JLabel label = createChartComponent(chart); JComponent scrollablePreview = new UiScrollPane(label); scrollablePreview.setBorder(new EmptyBorder(5, 5, 5, 5)); return scrollablePreview; }
From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java
private void layoutGuiComponents() { ///*from www. j a va 2 s . co m*/ // top level panel // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(new EmptyBorder(24, 24, 24, 24)); add(ignoreConflictsCheckbox); add(Box.createVerticalGlue()); }
From source file:com.emental.mindraider.ui.dialogs.FtsJDialog.java
public FtsJDialog() { super(Messages.getString("FtsJDialog.title")); JPanel dialogPanel = new JPanel(); dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10)); dialogPanel.setLayout(new BorderLayout()); JPanel contentAndButtons = new JPanel(new GridLayout(2, 1)); JPanel contentPanel = new JPanel(new BorderLayout()); // 1a./*w w w. j a v a2 s . com*/ // TODO add help like in eclipse contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH); // 1b. String[] knownSearches = new String[] { "", "RDF", "mind", "concept", "China" }; ftsCombo = new JComboBox(knownSearches); ftsCombo.setPreferredSize(new Dimension(200, 18)); ftsCombo.setEditable(true); ftsCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ("comboBoxEdited".equals(e.getActionCommand())) { search(); } } }); contentPanel.add(ftsCombo, BorderLayout.SOUTH); contentAndButtons.add(contentPanel); // 2. JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton")); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search(); } }); p.add(searchButton); JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); contentAndButtons.add(p); dialogPanel.add(contentAndButtons, BorderLayout.CENTER); getContentPane().add(dialogPanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:Main.java
/** * Set the button to have simplified UI. * /*from www. j av a 2 s .c o m*/ * @param button * button to be modified * @param <T> * type of button * @return button */ public static <T extends AbstractButton> T decoratedToSimpleButton(final T button) { button.setForeground(Color.BLACK); button.setBackground(Color.LIGHT_GRAY); button.setBorderPainted(true); button.setFocusPainted(true); button.setContentAreaFilled(false); button.setOpaque(true); if (button instanceof JToggleButton) { ((JToggleButton) button).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.isSelected()) { button.setBackground(Color.WHITE); } } }); } button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { super.mouseEntered(e); button.setBackground(Color.WHITE); } @Override public void mouseExited(MouseEvent e) { super.mouseExited(e); if (!button.isSelected()) { button.setBackground(Color.LIGHT_GRAY); } } }); button.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (!button.isSelected()) { button.setBackground(Color.LIGHT_GRAY); } } }); Border line = new LineBorder(Color.BLACK); Border margin = new EmptyBorder(5, 15, 5, 15); Border compound = new CompoundBorder(line, margin); button.setBorder(compound); return button; }
From source file:ColorMenu.java
public ColorMenu(String name) { super(name);// ww w .j a va2s. c o m _unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()), new BevelBorder(BevelBorder.LOWERED, Color.WHITE, Color.GRAY)); _selectedBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.RED), new MatteBorder(1, 1, 1, 1, getBackground())); _activeBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.BLUE), new MatteBorder(1, 1, 1, 1, getBackground())); JPanel p = new JPanel(); p.setBorder(new EmptyBorder(5, 5, 5, 5)); p.setLayout(new GridLayout(8, 8)); _colorPanes = new HashMap(); int values[] = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) for (int g = 0; g < values.length; g++) for (int b = 0; b < values.length; b++) { Color color = new Color(values[r], values[g], values[b]); ColorPane colorPane = new ColorPane(color); p.add(colorPane); _colorPanes.put(color, colorPane); } add(p); }
From source file:jmemorize.gui.swing.panels.SessionChartPanel.java
private void initComponents(LearnSession finishedSession) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(new EmptyBorder(5, 5, 5, 5)); LearnHistory history = Main.getInstance().getLesson().getLearnHistory(); SessionSummary lastSummary = history.getLastSummary(); add(createChartPanel(Localization.get(LC.CHART_THIS_SESSION), lastSummary)); add(createChartPanel(Localization.get(LC.CHART_AVERAGE_SESSION), history.getAverage())); setPreferredSize(new Dimension(500, 460)); }
From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java
public CompareViewPanel(Table<KnownColormap, ColormapQuality, Double> info) { this.table = info; setBorder(new EmptyBorder(5, 5, 5, 5)); setLayout(new BorderLayout()); JPanel statsPanel = new JPanel(new BorderLayout()); // statsLabel = new JLabel(); // statsLabel.setBorder(BorderFactory.createTitledBorder("Statistics")); // statsPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); statsBars = new JPanel(new GridBagLayout()); statsPanel.add(statsBars, BorderLayout.NORTH); // statsPanel.add(statsLabel, BorderLayout.SOUTH); add(statsPanel, BorderLayout.SOUTH); cmView = new ColormapPanel(new ConstantColormap(), 256); cmView.setBorder(new EmptyBorder(5, 0, 5, 0)); add(cmView, BorderLayout.CENTER); mapsCombo = new JComboBox<KnownColormap>(table.rowKeySet().toArray(new KnownColormap[0])); mapsCombo.addActionListener(new ActionListener() { @Override// w w w . j ava 2s .co m public void actionPerformed(ActionEvent e) { updateSelection(); } }); mapsCombo.setSelectedIndex(0); add(mapsCombo, BorderLayout.NORTH); }