List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java
private JPanel createUpdateSitePanel() { JPanel pnl = new JPanel(new GridBagLayout()); pnl.setBorder(BorderFactory.createTitledBorder(i18n.UPDATE_SITE_BORDER_LABEL)); ItemListener urlUpdateItemListener = new UrlItemListener(); DocumentListener urlDocumentListener = new UrlDocumentListener(); final GridBagConstraints gbc = new GridBagConstraints(); setSeparatorConstraints(gbc, 0);/*from w w w . j a v a2 s .c om*/ gbc.gridwidth = 1; gbc.weightx = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; siteTypeLabel = new JLabel(i18n.SITE_TYPE_LABEL, JLabel.RIGHT); pnl.add(siteTypeLabel, gbc); // Site type setSeparatorConstraints(gbc, 0); gbc.gridx = 1; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; pnl.add(getSiteTypePanel(), gbc); setSeparatorConstraints(gbc, 1); pnl.add(getSep(), gbc); // Update server name setLabelConstraints(gbc, 2); _serverLabel = new JLabel(i18n.SERVER, SwingConstants.RIGHT); pnl.add(_serverLabel, gbc); setFieldConstraints(gbc, 2); _updateServerName.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerName, gbc); // Update server port setLabelConstraints(gbc, 3); _portLabel = new JLabel(i18n.PORT, SwingConstants.RIGHT); pnl.add(_portLabel, gbc); setFieldConstraints(gbc, 3); _updateServerPort.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerPort, gbc); // Path to release.xml setLabelConstraints(gbc, 4); _pathLabel = new JLabel(i18n.PATH, SwingConstants.RIGHT); pnl.add(_pathLabel, gbc); setFieldConstraints(gbc, 4); _updateServerPath.getDocument().addDocumentListener(urlDocumentListener); pnl.add(_updateServerPath, gbc); // Channnel combo-box setLabelConstraints(gbc, 5); _channelLabel = new JLabel(i18n.CHANNEL, SwingConstants.RIGHT); pnl.add(_channelLabel, gbc); setFieldConstraints(gbc, 5); gbc.fill = GridBagConstraints.NONE; _updateServerChannel.addItemListener(urlUpdateItemListener); pnl.add(_updateServerChannel, gbc); // URL text field setLabelConstraints(gbc, 6); _urlLabel = new JLabel(i18n.URL, SwingConstants.RIGHT); pnl.add(_urlLabel, gbc); setFieldConstraints(gbc, 6); updateUrl(); pnl.add(_updateUrl, gbc); setFieldConstraints(gbc, 7); JLabel lblProxy = new JLabel(s_stringMgr.getString("UpdatePreferencesPanel.proxyHintHtml")); lblProxy.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblProxy.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { _prefrenceTabActvivationListener.activateTabForClass(ProxyPreferenceTabComponent.class); } }); pnl.add(lblProxy, gbc); // Test Connection Button Panel (Both the button and the status label setFieldConstraints(gbc, 8); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(_testConnectionButton); buttonBox.add(Box.createHorizontalStrut(20)); buttonBox.add(_testConnectionStatusLabel); _testConnectionButton.addActionListener(new TestConnectionButtonListener()); pnl.add(buttonBox, gbc); // Separator setSeparatorConstraints(gbc, 9); pnl.add(getSep(), gbc); // Local update directory setLabelConstraints(gbc, 10); _localPathLabel = new JLabel(i18n.LOCAL_PATH, SwingConstants.RIGHT); pnl.add(_localPathLabel, gbc); setFieldConstraints(gbc, 10); pnl.add(_localPath, gbc); return pnl; }
From source file:PolygonOffset.java
FloatLabelJSlider(String name, float resolution, float min, float max, float current) { this.resolution = resolution; this.min = min; this.max = max; this.current = current; if (resolution < minResolution) { resolution = minResolution;/*w w w. j a va 2s . co m*/ } // round scale to nearest integer fraction. i.e. 0.3 => 1/3 = 0.33 scale = (float) Math.round(1.0f / resolution); resolution = 1.0f / scale; // get the integer versions of max, min, current minInt = Math.round(min * scale); maxInt = Math.round(max * scale); curInt = Math.round(current * scale); // sliders use integers, so scale our floating point value by "scale" // to make each slider "notch" be "resolution". We will scale the // value down by "scale" when we get the event. slider = new JSlider(JSlider.HORIZONTAL, minInt, maxInt, curInt); slider.addChangeListener(this); valueLabel = new JLabel(" "); // set the initial value label setLabelString(); // add min and max labels to the slider Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(minInt), new JLabel(nf.format(min))); labelTable.put(new Integer(maxInt), new JLabel(nf.format(max))); slider.setLabelTable(labelTable); slider.setPaintLabels(true); /* layout to align left */ setLayout(new BorderLayout()); Box box = new Box(BoxLayout.X_AXIS); add(box, BorderLayout.WEST); box.add(new JLabel(name)); box.add(slider); box.add(valueLabel); }
From source file:PolygonOffset.java
LogFloatLabelJSlider(String name, float min, float max, float current) { this.resolution = resolution; this.min = min; this.max = max; this.current = current; if (resolution < minResolution) { resolution = minResolution;/*from w w w. j a v a 2 s . co m*/ } minLog = log10(min); maxLog = log10(max); curLog = log10(current); // resolution is 100 steps from min to max scale = 100.0f; resolution = 1.0f / scale; // get the integer versions of max, min, current minInt = (int) Math.round(minLog * scale); maxInt = (int) Math.round(maxLog * scale); curInt = (int) Math.round(curLog * scale); slider = new JSlider(JSlider.HORIZONTAL, minInt, maxInt, curInt); slider.addChangeListener(this); valueLabel = new JLabel(" "); // Need to muck around to make sure that the width of the label // is wide enough for the largest value. Pad the initial string // be large enough to hold the largest value. int pad = 5; // fudge to make up for variable width fonts intDigits = (int) Math.ceil(maxLog) + pad; if (min < 0) { intDigits++; // add one for the '-' } if (minLog < 0) { fractDigits = (int) Math.ceil(-minLog); } else { fractDigits = 0; } nf.setMinimumFractionDigits(fractDigits); nf.setMaximumFractionDigits(fractDigits); String value = nf.format(current); while (value.length() < (intDigits + fractDigits)) { value = value + " "; } valueLabel.setText(value); // add min and max labels to the slider Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(minInt), new JLabel(nf.format(min))); labelTable.put(new Integer(maxInt), new JLabel(nf.format(max))); slider.setLabelTable(labelTable); slider.setPaintLabels(true); // layout to align left setLayout(new BorderLayout()); Box box = new Box(BoxLayout.X_AXIS); add(box, BorderLayout.WEST); box.add(new JLabel(name)); box.add(slider); box.add(valueLabel); }
From source file:pcgen.gui2.tabs.bio.BiographyInfoPane.java
private void initComponents() { setLayout(new GridBagLayout()); Box vbox = Box.createVerticalBox(); allButton.setText(LanguageBundle.getString("in_all")); //$NON-NLS-1$ allButton.setActionCommand(ALL_COMMAND); noneButton.setText(LanguageBundle.getString("in_none")); //$NON-NLS-1$ noneButton.setActionCommand(NONE_COMMAND); Box hbox = Box.createHorizontalBox(); hbox.add(new JLabel(LanguageBundle.getString("in_descCheckItem"))); //$NON-NLS-1$ hbox.add(Box.createRigidArea(new Dimension(5, 0))); hbox.add(allButton);/*from w ww . j a v a 2 s. co m*/ hbox.add(Box.createRigidArea(new Dimension(3, 0))); hbox.add(noneButton); vbox.add(hbox); itemsPanel.setLayout(new GridBagLayout()); itemsPanel.setBorder(new EmptyBorder(8, 5, 8, 5)); vbox.add(Box.createVerticalStrut(10)); detailsScroll = new JScrollPane(itemsPanel); detailsScroll.setPreferredSize(detailsScroll.getMaximumSize()); detailsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); detailsScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); detailsScroll.setMinimumSize(new Dimension(600, 0)); vbox.add(detailsScroll); vbox.add(Box.createVerticalStrut(10)); hbox = Box.createHorizontalBox(); hbox.add(Box.createHorizontalGlue()); addCustomItemButton = new JButton(); hbox.add(addCustomItemButton); hbox.add(Box.createHorizontalGlue()); vbox.add(hbox); vbox.add(Box.createVerticalGlue()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = 1; gbc.fill = GridBagConstraints.VERTICAL; gbc.weighty = 1; gbc.insets = new Insets(5, 5, 5, 5); add(vbox, gbc); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel logPanel() { _logScreen = new JTextArea(); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(new JScrollPane(_logScreen)); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(new SaveAction(_logScreen))); buttons.add(new JButton(new ClearAction(_logScreen))); panel.add(buttons, BorderLayout.SOUTH); return panel; }
From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java
private void createOntologySelectionPanel() { OntologyListRenderer listRenderer = new OntologyListRenderer(); JPanel westPanel = new JPanel(new BorderLayout()); JPanel selectedOntologiesContainer = new JPanel(new BorderLayout()); selectedOntologiesContainer.setOpaque(false); // create List containing selected ontologies selectedOntologyListModel = new DefaultListModel(); selectedOntologyList = new JList(selectedOntologyListModel); selectedOntologyList.setCellRenderer(new SelectedOntologyListRenderer()); selectedOntologyList.setBackground(UIHelper.BG_COLOR); selectedOntologyList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { setOntologySelectionPanelPlaceholder(infoImage); setSelectedOntologyButtonVisibility(selectedOntologyList.isSelectionEmpty()); }/*from w w w . ja v a2s .c o m*/ }); JScrollPane selectedOntologiesScroller = new JScrollPane(selectedOntologyList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); selectedOntologiesScroller.setPreferredSize(new Dimension(200, 255)); selectedOntologiesScroller.setBackground(UIHelper.BG_COLOR); selectedOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR); IAppWidgetFactory.makeIAppScrollPane(selectedOntologiesScroller); selectedOntologiesContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "selected ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); selectedOntologiesContainer.add(selectedOntologiesScroller, BorderLayout.CENTER); // ADD BUTTONS removeOntologyButton = new JLabel(removeOntologyButtonIcon); removeOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!selectedOntologyList.isSelectionEmpty()) { String ontologyToRemove = selectedOntologyList.getSelectedValue().toString(); System.out.println("Removing " + ontologyToRemove); selectedOntologies.remove(ontologyToRemove); setOntologySelectionPanelPlaceholder(infoImage); updateSelectedOntologies(); } removeOntologyButton.setIcon(removeOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { removeOntologyButton.setIcon(removeOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeOntologyButton.setIcon(removeOntologyButtonIcon); } }); removeOntologyButton.setVisible(false); viewOntologyButton = new JLabel(browseOntologyButtonIcon); viewOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { performTransition(); viewOntologyButton.setIcon(browseOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { viewOntologyButton.setIcon(browseOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { viewOntologyButton.setIcon(browseOntologyButtonIcon); } }); viewOntologyButton.setVisible(false); removeRestrictionButton = new JLabel(removeRestrictionButtonIcon); removeRestrictionButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!selectedOntologyList.isSelectionEmpty()) { ((RecommendedOntology) selectedOntologyList.getSelectedValue()).setBranchToSearchUnder(null); removeRestrictionButton.setVisible(false); selectedOntologyList.repaint(); } removeRestrictionButton.setIcon(removeRestrictionButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { removeRestrictionButton.setIcon(removeRestrictionButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeRestrictionButton.setIcon(removeRestrictionButtonIcon); } }); removeRestrictionButton.setVisible(false); Box selectedOntologiesOptionContainer = Box.createHorizontalBox(); selectedOntologiesOptionContainer.setOpaque(false); selectedOntologiesOptionContainer.add(removeOntologyButton); selectedOntologiesOptionContainer.add(viewOntologyButton); selectedOntologiesOptionContainer.add(removeRestrictionButton); selectedOntologiesContainer.add(selectedOntologiesOptionContainer, BorderLayout.SOUTH); // create panel populated with all available ontologies inside a filterable list! JPanel availableOntologiesListContainer = new JPanel(new BorderLayout()); availableOntologiesListContainer .setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "available ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); final ExtendedJList availableOntologies = new ExtendedJList(listRenderer); final JLabel addOntologyButton = new JLabel(addOntologyButtonIcon); addOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!availableOntologies.isSelectionEmpty()) { Ontology ontology = (Ontology) availableOntologies.getSelectedValue(); selectedOntologies.put(ontology.getOntologyDisplayLabel(), new RecommendedOntology(ontology)); updateSelectedOntologies(); setOntologySelectionPanelPlaceholder(infoImage); } addOntologyButton.setIcon(addOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { addOntologyButton.setIcon(addOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addOntologyButton.setIcon(addOntologyButtonIcon); } }); final JLabel info = UIHelper.createLabel("", UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR); availableOntologies.addPropertyChangeListener("update", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { info.setText("<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>"); } }); Box optionsBox = Box.createVerticalBox(); optionsBox.add(UIHelper.wrapComponentInPanel(info)); Box availableOntologiesOptionBox = Box.createHorizontalBox(); availableOntologiesOptionBox.add(addOntologyButton); availableOntologiesOptionBox.add(Box.createHorizontalGlue()); optionsBox.add(availableOntologiesOptionBox); availableOntologiesListContainer.add(optionsBox, BorderLayout.SOUTH); if (ontologiesToBrowseOn == null) { ontologiesToBrowseOn = new ArrayList<Ontology>(); List<Ontology> bioportalQueryResult = bioportalClient.getAllOntologies(); if (bioportalQueryResult != null) { ontologiesToBrowseOn.addAll(bioportalQueryResult); } ontologiesToBrowseOn.addAll(olsClient.getAllOntologies()); } // precautionary check in case of having no ontologies available to search on. if (ontologiesToBrowseOn != null) { for (Ontology o : ontologiesToBrowseOn) { availableOntologies.addItem(o); } } info.setText( "<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>"); // need to get ontologies available from bioportal and add them here. JScrollPane availableOntologiesScroller = new JScrollPane(availableOntologies, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); availableOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR); availableOntologiesScroller.setPreferredSize(new Dimension(200, 125)); availableOntologiesScroller.setBorder(new EmptyBorder(0, 0, 0, 0)); IAppWidgetFactory.makeIAppScrollPane(availableOntologiesScroller); availableOntologiesListContainer.add(availableOntologiesScroller); availableOntologiesListContainer.add(availableOntologies.getFilterField(), BorderLayout.NORTH); westPanel.add(selectedOntologiesContainer, BorderLayout.CENTER); westPanel.add(availableOntologiesListContainer, BorderLayout.SOUTH); add(westPanel, BorderLayout.WEST); }
From source file:cloud.gui.CloudGUI.java
private void createNumberOfInstancesStatus(Box layout) { JLabel nn = new JLabel("Number of current instances: ", JLabel.CENTER); Box horizonLayout = Box.createHorizontalBox(); numberOfNodesLbl = new JLabel("0", JLabel.CENTER); horizonLayout.add(nn); horizonLayout.add(numberOfNodesLbl); layout.add(horizonLayout);//ww w .j av a 2 s . c o m }
From source file:cloud.gui.CloudGUI.java
private void createTotalCost(Box layout) { JLabel nn = new JLabel("Total Cost: ", JLabel.CENTER); Box horizonLayout = Box.createHorizontalBox(); totalCostValueLbl = new JLabel("0", JLabel.CENTER); horizonLayout.add(nn); horizonLayout.add(totalCostValueLbl); layout.add(horizonLayout);//from w ww .j a v a2 s .c om }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel analysePanel() { _analysisScreen = new JTextArea(); Box buttons = Box.createVerticalBox(); buttons.add(new JLabel("Find frequency of nodes used by model when scanning scenes")); JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1)); JPanel labelledSpinner = new JPanel(); labelledSpinner.setLayout(new GridLayout(1, 2)); labelledSpinner.add(new JLabel("Number of fixations: ", SwingConstants.RIGHT)); labelledSpinner.add(numFixations);//from ww w .j a v a 2s . c o m buttons.add(labelledSpinner); buttons.add(runAnalysisButtons(numFixations)); // main panel JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(buttons, BorderLayout.NORTH); panel.add(new JScrollPane(_analysisScreen)); Box displayButtons = Box.createHorizontalBox(); displayButtons.add(new JButton(new SaveAction(_analysisScreen))); displayButtons.add(new JButton(new ClearAction(_analysisScreen))); panel.add(displayButtons, BorderLayout.SOUTH); return panel; }
From source file:com.diversityarrays.kdxplore.heatmap.HeatMapPanel.java
private JComponent createCurationControls() { rejectSamplesAction.setEnabled(false); acceptSamplesAction.setEnabled(false); deActivatePlotsAction.setEnabled(false); reActivatePlotsAction.setEnabled(false); // | deactivate // accept suppress | reactivate JPanel panel = new JPanel(); GBH gbh = new GBH(panel, 2, 2, 2, 2); gbh.add(0, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(acceptSamplesAction)); gbh.add(1, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(rejectSamplesAction)); // if (! askAboutValueForUnscored) { // // TODO i18n // gbh.add(0,1, 2,1, GBH.HORZ, 1,1, GBH.CENTER, "Unscored samples ignored"); // }//from w w w. j a v a 2 s . c o m if (xValueRetriever.isPlotColumn() && yValueRetriever.isPlotRow()) { gbh.add(2, 0, 1, 2, GBH.VERT, 1, 1, GBH.CENTER, new JSeparator(JSeparator.VERTICAL)); gbh.add(3, 0, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(deActivatePlotsAction)); gbh.add(3, 1, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(reActivatePlotsAction)); } if (markInfo != null) { JComboBox<String> combo = new JComboBox<>(); combo.addItem(NO_MARK); for (String s : markInfo.plotPointsByMark.keySet()) { combo.addItem(s); } combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Point> points = null; Object item = combo.getSelectedItem(); if (item != null && !NO_MARK.equals(item)) { points = markInfo.plotPointsByMark.get(item); markName = item.toString(); } if (Check.isEmpty(points)) { heatMap.removeDecoratedPoints(markInfoRenderer); } else { heatMap.setDecoratedPoints(markInfoRenderer, points.toArray(new Point[points.size()])); } } }); Box newBox = Box.createHorizontalBox(); newBox.add(new JLabel(markInfo.label)); newBox.add(combo); gbh.add(0, 2, 4, 1, GBH.HORZ, 1, 1, GBH.CENTER, newBox); } return panel; }