List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:io.github.tavernaextras.biocatalogue.ui.filtertree.FilterTreePane.java
/** * @return A toolbar that replicates all actions available in the contextual menu of * the filtering tree - mainly: saving current filter, reloading filter tree, * expanding/collapsing and selecting/deselecting everything in the tree. *//*from www .ja v a2 s. co m*/ private JToolBar createTreeActionToolbar() { // the actual toolbar - no actions are added to it yet: done in a separate method JToolBar tbTreeActions = new JToolBar(JToolBar.HORIZONTAL); tbTreeActions.setAlignmentX(RIGHT_ALIGNMENT); tbTreeActions.setBorderPainted(true); tbTreeActions.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tbTreeActions.setFloatable(false); return (tbTreeActions); }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private JPanel getBottomPanel() { final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); bottomPanel.add(Box.createHorizontalGlue()); final JButton cancelButton = ButtonFactory.createCancelButton(); cancelButton.addActionListener(new ActionListener() { @Override//from ww w . java 2 s. c om public void actionPerformed(final ActionEvent e) { LinkUnlinkWindow.this.dispose(); } }); bottomPanel.add(cancelButton); bottomPanel.add(Box.createHorizontalStrut(10)); final JButton okButton = ButtonFactory.createOkButton(); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actuallyLinkUnlink(); LinkUnlinkWindow.this.dispose(); } }); bottomPanel.add(okButton); bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20)); return bottomPanel; }
From source file:ListSelectionDemo.java
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = { "one", "two", "three", "four", "five", "six", "seven" }; String[] columnNames = { "French", "Spanish", "Italian" }; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);// www . j ava 2s . c om comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
From source file:edu.ku.brc.specify.ui.db.AskForNumbersDlg.java
@Override public void createUI() { super.createUI(); textArea = UIHelper.createTextArea(5, 30); errorPanel = new NumberEditorPanel(textArea, this, "AFN_NUMFMT_ERROR"); missingPanel = new NumberEditorPanel(textArea, this, "AFN_NOTFND_ERROR"); CellConstraints cc = new CellConstraints(); pb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p,4px,f:p:g,4px,f:p:g")); pb.addSeparator(UIRegistry.getResourceString(labelKey), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(textArea), cc.xy(1, 3)); contentPanel = pb.getPanel();//from www .ja va 2s .co m mainPanel.add(contentPanel, BorderLayout.CENTER); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); textArea.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { checkStatus(); } }); getOkBtn().setEnabled(false); pack(); }
From source file:ContainerEventDemo.java
public ContainerEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); //Initialize an empty list of buttons. buttonList = new Vector(10, 10); //Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);/*www . j a v a 2 s. c o m*/ addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; //Fill entire cell. c.weighty = 1.0; //Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; //Add/remove buttons have equal width. c.gridwidth = 1; //NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; //end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; //Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:DecimalFormatDemo.java
public DecimalFormatDemo() { availableLocales = new LocaleGroup(); inputFormatter = NumberFormat.getNumberInstance(); String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000", "'hello'###.##" }; currentPattern = patternExamples[0]; // Set up the UI for entering a number. JLabel numberLabel = new JLabel("Enter the number to format:"); numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JTextField numberField = new JTextField(); numberField.setEditable(true);/*from ww w . jav a2 s . c o m*/ numberField.setAlignmentX(Component.LEFT_ALIGNMENT); NumberListener numberListener = new NumberListener(); numberField.addActionListener(numberListener); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0); patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Result", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel numberPanel = new JPanel(); numberPanel.setLayout(new GridLayout(0, 1)); numberPanel.add(numberLabel); numberPanel.add(numberField); JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(numberPanel); add(Box.createVerticalStrut(10)); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); numberField.setText(result.getText()); }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
/** * Returns the main node panel./* w ww .ja va 2s.co m*/ * * @return the panel */ private void initUI() { // TOP; JPanel top = new JPanel(); top.setLayout(new VerticalFlowLayout(VerticalFlowLayout.FILL)); top.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 10)); // Top node path. AlignmentGridPanel pathPanel = new AlignmentGridPanel(); pathText.setEditable(false); pathPanel.addLine(new Component[] { new JLabel("Path: "), pathText }); // Top buttons CButtonPane topButtons = new CButtonPane(CButtonPane.HORIZONTAL, CButtonPane.HEAD); topButtons.add(jbDelete); topButtons.add(jbNewChild); topButtons.add(jbUpdate); topButtons.add(jbRefresh); topButtons.add(jbEnableEdit, CButtonPane.TAIL); top.add(pathPanel); top.add(new JSeparator()); top.add(this.jzvStat); top.add(new JSeparator()); top.add(topButtons); //top.add(new JSeparator()); // Center. JPanel center = new JPanel(new BorderLayout(5, 5)); center.add(new RTextScrollPane(this.taUpdate), "Center"); center.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); this.add(top, "North"); this.add(center, "Center"); }
From source file:Converter.java
/** * Create the ConversionPanels (one for metric, another for U.S.). I used * "U.S." because although Imperial and U.S. distance measurements are the * same, this program could be extended to include volume measurements, which * aren't the same./* w w w. ja v a 2s. c om*/ */ public Converter() { // Create Unit objects for metric distances, and then // instantiate a ConversionPanel with these Units. metricDistances[0] = new Unit("Centimeters", 0.01); metricDistances[1] = new Unit("Meters", 1.0); metricDistances[2] = new Unit("Kilometers", 1000.0); metricPanel = new ConversionPanel(this, "Metric System", metricDistances, dataModel); // Create Unit objects for U.S. distances, and then // instantiate a ConversionPanel with these Units. usaDistances[0] = new Unit("Inches", 0.0254); usaDistances[1] = new Unit("Feet", 0.305); usaDistances[2] = new Unit("Yards", 0.914); usaDistances[3] = new Unit("Miles", 1613.0); usaPanel = new ConversionPanel(this, "U.S. System", usaDistances, new FollowerRangeModel(dataModel)); // Create a JPanel, and add the ConversionPanels to it. mainPane = new JPanel(); mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { mainPane.setOpaque(true); mainPane.setBackground(new Color(255, 0, 0)); } mainPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); mainPane.add(metricPanel); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); mainPane.add(usaPanel); mainPane.add(Box.createGlue()); resetMaxValues(true); }
From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java
public static void main(String[] args) { try {// w w w. ja va 2 s. c om com.jidesoft.utils.Lm.verifyLicense("UIN", "BrainFlow", "S5XiLlHH0VReaWDo84sDmzPxpMJvjP3"); //com.jidesoft.plaf.LookAndFeelFactory.installDefaultLookAndFeel(); //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2007_STYLE); UIManager.setLookAndFeel(new NimbusLookAndFeel()); JFrame jf = new JFrame(); FileObjectGroupSelector selector = new FileObjectGroupSelector( VFS.getManager().resolveFile("c:/javacode")); ButtonPanel buttonPanel = new ButtonPanel(SwingConstants.RIGHT); buttonPanel.setSizeConstraint(ButtonPanel.NO_LESS_THAN); JButton okButton = new JButton("OK"); JButton resetButton = new JButton("Cancel"); buttonPanel.addButton(okButton, ButtonPanel.AFFIRMATIVE_BUTTON); buttonPanel.addButton(resetButton, ButtonPanel.CANCEL_BUTTON); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 8, 8)); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(selector, BorderLayout.CENTER); panel.add(buttonPanel, BorderLayout.SOUTH); panel.setMinimumSize(new Dimension(800, 100)); jf.add(panel, BorderLayout.CENTER); jf.pack(); jf.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);/*from ww w .j av a2 s . c om*/ //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }