List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:components.FrameDemo2.java
protected JComponent createOptionControls() { JLabel label1 = new JLabel("Decoration options for subsequently created frames:"); ButtonGroup bg1 = new ButtonGroup(); JLabel label2 = new JLabel("Icon options:"); ButtonGroup bg2 = new ButtonGroup(); //Create the buttons JRadioButton rb1 = new JRadioButton(); rb1.setText("Look and feel decorated"); rb1.setActionCommand(LF_DECORATIONS); rb1.addActionListener(this); rb1.setSelected(true);/*from ww w . j a v a 2 s.c o m*/ bg1.add(rb1); // JRadioButton rb2 = new JRadioButton(); rb2.setText("Window system decorated"); rb2.setActionCommand(WS_DECORATIONS); rb2.addActionListener(this); bg1.add(rb2); // JRadioButton rb3 = new JRadioButton(); rb3.setText("No decorations"); rb3.setActionCommand(NO_DECORATIONS); rb3.addActionListener(this); bg1.add(rb3); // // JRadioButton rb4 = new JRadioButton(); rb4.setText("Default icon"); rb4.setActionCommand(DEFAULT_ICON); rb4.addActionListener(this); rb4.setSelected(true); bg2.add(rb4); // JRadioButton rb5 = new JRadioButton(); rb5.setText("Icon from a JPEG file"); rb5.setActionCommand(FILE_ICON); rb5.addActionListener(this); bg2.add(rb5); // JRadioButton rb6 = new JRadioButton(); rb6.setText("Painted icon"); rb6.setActionCommand(PAINT_ICON); rb6.addActionListener(this); bg2.add(rb6); //Add everything to a container. Box box = Box.createVerticalBox(); box.add(label1); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb1); box.add(rb2); box.add(rb3); // box.add(Box.createVerticalStrut(15)); //spacer box.add(label2); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb4); box.add(rb5); box.add(rb6); //Add some breathing room. box.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return box; }
From source file:com.sshtools.common.ui.SshToolsConnectionPanel.java
/** * * * @param parent/* w w w .j a va2 s . c o m*/ * @param profile * @param optionalTabs * * @return */ public static SshToolsConnectionProfile showConnectionDialog(Component parent, SshToolsConnectionProfile profile, SshToolsConnectionTab[] optionalTabs) { // If no properties are provided, then use the default if (profile == null) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile = new SshToolsConnectionProfile(); profile.setHost(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_HOST, "")); profile.setPort(PreferencesStore.getInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, port)); profile.setUsername(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_USER, "")); } final SshToolsConnectionPanel conx = new SshToolsConnectionPanel(true); if (optionalTabs != null) { for (int i = 0; i < optionalTabs.length; i++) { conx.addTab(optionalTabs[i]); } } conx.setConnectionProfile(profile); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Connection Profile", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Connection Profile", true); } else { d = new JDialog((JFrame) null, "Connection Profile", true); } final JDialog dialog = d; class UserAction { boolean connect; } final UserAction userAction = new UserAction(); // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { userAction.connect = false; dialog.setVisible(false); } }); final JButton connect = new JButton("Connect"); connect.setMnemonic('t'); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (conx.validateTabs()) { userAction.connect = true; dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(connect); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, connect, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(conx, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(false); UIUtil.positionComponent(SwingConstants.CENTER, dialog); //show the simple box and act on the answer. SshToolsSimpleConnectionPrompt stscp = SshToolsSimpleConnectionPrompt.getInstance(); StringBuffer sb = new StringBuffer(); userAction.connect = !stscp.getHostname(sb, profile.getHost()); boolean advanced = stscp.getAdvanced(); if (advanced) { userAction.connect = false; profile.setHost(sb.toString()); conx.hosttab.setConnectionProfile(profile); dialog.setVisible(true); } // Make sure we didn't cancel if (!userAction.connect) { return null; } conx.applyTabs(); if (!advanced) profile.setHost(sb.toString()); if (!advanced) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile.setPort(port); } if (!advanced) profile.setUsername(""); PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_HOST, profile.getHost()); // only save user inputed configuration if (advanced) { PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_USER, profile.getUsername()); PreferencesStore.putInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, profile.getPort()); } // Return the connection properties return profile; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.corretor_eventos.PanelCorretorEventos.java
/** * Cria uma borda com ttulo dentro dos padres * /* ww w . ja v a2s.co m*/ * @param titulo * @return */ private Border criaBorda(String titulo) { Border bordaLinhaPreta = BorderFactory.createLineBorder(new Color(0, 0, 0), 1); Border borda = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5), new TitledBorder(bordaLinhaPreta, titulo)); Border bordaFinal = BorderFactory.createCompoundBorder(borda, BorderFactory.createEmptyBorder(0, 4, 4, 5)); return bordaFinal; }
From source file:de.unidue.inf.is.ezdl.gframedl.components.checkboxlist.CheckBoxListCellRenderer.java
private void makeDescriptionText(List<String> lines) { StringBuilder textBuilder = new StringBuilder(); if (lines.size() > 1) { String lastLine = lines.get(1); if (lines.size() > 2) { lastLine = StringUtils.abbreviate(lastLine, lastLine.length() - 1); }//from w w w . j a v a 2 s . c om textBuilder.append(lines.get(0)).append("\n").append(lastLine); description.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } else if (lines.size() > 0) { textBuilder.append(lines.get(0)); description.setBorder(BorderFactory.createEmptyBorder(16, 10, 10, 10)); } description.setText(textBuilder.toString()); }
From source file:gui.GraphsPanel.java
/** TV constructor for DendrogramsPanel to be called when clustering SNP marker data. * /*from w w w . ja va 2 s. c o m*/ */ public GraphsPanel(Cluster cluster, int tpmmode) { this.cluster = cluster; graph = cluster.getGraph(); final Factory<TreeNode> vertexFactory = new Factory<TreeNode>() { TreeNode treeVertice; public TreeNode create() { return treeVertice; } }; final Factory<TreeNode> edgeFactory = new Factory<TreeNode>() { TreeNode treeEdge; public TreeNode create() { return treeEdge; } }; balloonLayout = new BalloonLayout<TreeNode, TreeNode>(graph); radialLayout = new RadialTreeLayout<TreeNode, TreeNode>((Forest<TreeNode, TreeNode>) graph, 10000, 10000); vv = new VisualizationViewer<TreeNode, TreeNode>(radialLayout); vv.setBackground(Color.white); vv.setVertexToolTipTransformer(vertexString); vv.setEdgeToolTipTransformer(edgeString); vv.getRenderContext().setArrowFillPaintTransformer(arrowFillColor); vv.getRenderContext().setArrowDrawPaintTransformer(arrowColor); vv.getRenderContext().setEdgeDrawPaintTransformer(edgeColor); balloonrings = new BalloonRings(balloonLayout); radialrings = new RadialRings(radialLayout); EditingModalGraphMouse<TreeNode, TreeNode> gm = new EditingModalGraphMouse<TreeNode, TreeNode>( vv.getRenderContext(), vertexFactory, edgeFactory); gm.add(new ReEditingPopupGraphMousePlugin<TreeNode, TreeNode>(vertexFactory, edgeFactory)); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); vv.getRenderContext().setVertexFillPaintTransformer(vertexColor); vv.getRenderContext().setVertexShapeTransformer(vertexSize); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<TreeNode, TreeNode>()); // final GraphZoomScrollPane zoomScrollPane = new GraphZoomScrollPane(this.vv); this.setLayout(new BorderLayout()); this.add(zoomScrollPane, BorderLayout.CENTER); this.toolbar = new GraphToolBar(this);// , canvas, chart); this.add(toolbar, BorderLayout.EAST); this.label = new JLabel("<html><table><tr><td> Similarity: " + Prefs.d3.format(this.getThreshold()) + "</td><td> Groups: " + cluster.getAvLnkDendrogram().getGroupCount(this.getThreshold()) + "</td><td> </td><td> Distinctiveness: " + Prefs.d3.format(this.getSensitivity()) + "</td><td> Subgroups: " + cluster.getAvLnkDendrogram().getWeakEdgeCount(this.getSensitivity()) + "</td></tr></table></html>"); this.label.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); this.add(label, BorderLayout.SOUTH); this.setVisible(true); }
From source file:org.rdv.viz.dial.DialPanel.java
/** * Creates the panel containing settings. * /*w w w.j av a2 s.c o m*/ * @return the settings panel */ private JPanel createSettingsPanel() { JPanel settingsPanel = new JPanel(); settingsPanel.setLayout(new BorderLayout()); settingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); lowerBoundTextField = new JTextField(6); lowerBoundTextField.setToolTipText("The minimum value for the dial"); lowerBoundTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setRangeFromTextFields(); } }); settingsPanel.add(lowerBoundTextField, BorderLayout.LINE_START); upperBoundTextField = new JTextField(6); upperBoundTextField.setToolTipText("The maximum value for the dial"); upperBoundTextField.setHorizontalAlignment(JTextField.TRAILING); upperBoundTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setRangeFromTextFields(); } }); settingsPanel.add(upperBoundTextField, BorderLayout.LINE_END); return settingsPanel; }
From source file:com.intel.stl.ui.main.view.StaDetailsPanel.java
/** * Description://ww w .j a v a2 s.c om * * @param sourceName */ protected void initComponent() { setLayout(new BorderLayout(0, 10)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.insets = new Insets(2, 2, 2, 2); gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1; gc.gridwidth = 1; gc.weighty = 0; failedChartPanel = new ChartPanel(null); failedChartPanel.setPreferredSize(new Dimension(60, 20)); mainPanel.add(failedChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.weightx = 0; failedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD); failedNumberLabel.setForeground(UIConstants.INTEL_DARK_RED); failedNumberLabel.setHorizontalAlignment(JLabel.CENTER); mainPanel.add(failedNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; failedNameLabel = ComponentFactory.getH5Label(STLConstants.K0020_FAILED.getValue(), Font.PLAIN); failedNameLabel.setVerticalAlignment(JLabel.BOTTOM); mainPanel.add(failedNameLabel, gc); gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1; gc.gridwidth = 1; skippedChartPanel = new ChartPanel(null); skippedChartPanel.setPreferredSize(new Dimension(60, 20)); mainPanel.add(skippedChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.weightx = 0; skippedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD); skippedNumberLabel.setForeground(UIConstants.INTEL_DARK_ORANGE); skippedNumberLabel.setHorizontalAlignment(JLabel.CENTER); mainPanel.add(skippedNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; skippedNameLabel = ComponentFactory.getH5Label(STLConstants.K0021_SKIPPED.getValue(), Font.PLAIN); skippedNameLabel.setVerticalAlignment(JLabel.BOTTOM); mainPanel.add(skippedNameLabel, gc); gc.weighty = 0; gc.fill = GridBagConstraints.NONE; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = types.length; typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); typeNumberLabels = new JLabel[types.length]; typeNameLabels = new JLabel[types.length]; gc.fill = GridBagConstraints.BOTH; gc.gridheight = 1; gc.insets = new Insets(12, 2, 2, 2); for (int i = 0; i < types.length; i++) { if (i == 1) { gc.insets = new Insets(2, 2, 2, 2); } gc.weightx = 0; gc.gridwidth = 1; typeNumberLabels[i] = createNumberLabel(); mainPanel.add(typeNumberLabels[i], gc); gc.gridwidth = GridBagConstraints.REMAINDER; typeNameLabels[i] = createNameLabel(types[i].getName()); mainPanel.add(typeNameLabels[i], gc); } gc.fill = GridBagConstraints.BOTH; mainPanel.add(Box.createGlue(), gc); add(mainPanel, BorderLayout.CENTER); }
From source file:BRHInit.java
public void showVPSPrompt(JSONArray vps) throws Exception { vps_list = vps;/*from ww w . j a v a 2 s . c o m*/ if (vps_list_window == null) { vps_list_window = new JFrame("BRH Console"); vps_list_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel top_panel = new JPanel(); vps_list_window.getContentPane().add(top_panel); top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS)); top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); Vector values = new Vector(); for (int idx = 0; idx < vps_list.length(); ++idx) { JSONArray row = vps_list.getJSONArray(idx); values.addElement(row.getString(1)); } vps_list_box = new JList(values); top_panel.add(new JScrollPane(vps_list_box)); vps_list_box.setVisibleRowCount(10); JPanel p = new JPanel(); 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()); 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(vps_list_ok = new JButton("OK")); p.add(Box.createRigidArea(new Dimension(5, 0))); p.add(vps_list_cancel = new JButton("Cancel")); p.add(Box.createHorizontalGlue()); vps_list_ok.addActionListener(this); vps_list_cancel.addActionListener(this); vps_list_window.pack(); } vps_list_window.setVisible(true); }
From source file:com.rapidminer.template.gui.RoleRequirementSelector.java
public RoleRequirementSelector(final TemplateController controller) { super(new BorderLayout()); setBorder(border);/* www . ja v a 2 s.co m*/ this.controller = controller; setBackground(Color.WHITE); updateRequirement(); controller.getModel().addObserver(new Observer() { @Override public void update(Observable o, Object arg) { if (TemplateState.OBSERVER_EVENT_TEMPLATE.equals(arg)) { updateRequirement(); updateComponents(); } else if (TemplateState.OBSERVER_EVENT_ROLES.equals(arg)) { assignSelectionToCombo(); updateComponents(); attributeCombo.repaint(); } else if (TemplateState.OBSERVER_EVENT_INPUT.equals(arg)) { updateAttributes(); } } }); AutoCompleteDecorator.decorate(attributeCombo); AutoCompleteDecorator.decorate(positiveClassCombo); attributeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (areValuesAdjusting) { return; } assignRoles(); } }); positiveClassCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (areValuesAdjusting) { return; } assignRoles(); } }); helpLabel.setHorizontalAlignment(SwingConstants.CENTER); add(helpLabel, BorderLayout.PAGE_START); chartPanel = new ChartPanel(null, 250, 250, 100, 100, 360, 360, true, false, false, false, false, false); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); attributeCombo.setPreferredSize(new Dimension(100, 30)); attributeCombo.setMaximumSize(new Dimension(150, 30)); add(chartPanel, BorderLayout.CENTER); JComponent comboPanel = new JPanel(); comboPanel.setLayout(new BoxLayout(comboPanel, BoxLayout.PAGE_AXIS)); JComponent comboPanelAtt = new JPanel(); comboPanelAtt.setBackground(Color.WHITE); comboPanelAtt.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); JComponent comboPanelClass = new JPanel(); comboPanelClass.setBackground(Color.WHITE); comboPanelClass.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); positiveClassCombo.setPreferredSize(new Dimension(100, 30)); positiveClassCombo.setMaximumSize(new Dimension(150, 30)); positiveClassLabel.setLabelFor(positiveClassCombo); positiveClassLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); positiveClassLabel.setToolTipText(positiveClassLabel.getText()); positiveClassLabel.setHorizontalAlignment(SwingConstants.RIGHT); columnLabel.setLabelFor(attributeCombo); columnLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); columnLabel.setToolTipText(columnLabel.getText()); columnLabel.setHorizontalAlignment(SwingConstants.RIGHT); comboPanelAtt.add(columnLabel); comboPanelAtt.add(attributeCombo); comboPanelClass.add(positiveClassLabel); comboPanelClass.add(positiveClassCombo); comboPanel.add(comboPanelAtt); comboPanel.add(comboPanelClass); add(comboPanel, BorderLayout.SOUTH); updateComponents(); }
From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
private void addCloseButton() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(Box.createHorizontalGlue()); JButton button = new JButton(i18n.getString(I18n.BUTTON_CLOSE_ID)); panel.add(button);//w w w . ja va 2 s . c om panel.add(Box.createHorizontalGlue()); button.addActionListener(closeAction()); panel.setBorder(BorderFactory.createEmptyBorder(border, 0, 0, 0)); add(panel, BorderLayout.SOUTH); }