List of usage examples for javax.swing Box createRigidArea
public static Component createRigidArea(Dimension d)
From source file:savant.view.swing.NavigationBar.java
private static Component getRigidPadding() { return Box.createRigidArea(new Dimension(7, 7)); }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Create the JMeter tool bar pane containing the running indicator. * * @return a panel containing the running indicator *//*from w w w .j a v a2 s .co m*/ private Component createToolBar() { Box toolPanel = new Box(BoxLayout.X_AXIS); // add the toolbar this.toolbar = JMeterToolBar.createToolbar(true); GuiPackage guiInstance = GuiPackage.getInstance(); guiInstance.setMainToolbar(toolbar); toolPanel.add(toolbar); toolPanel.add(Box.createRigidArea(new Dimension(10, 15))); toolPanel.add(Box.createGlue()); toolPanel.add(testTimeDuration); toolPanel.add(Box.createRigidArea(new Dimension(20, 15))); toolPanel.add(errorsOrFatalsLabel); toolPanel.add(warnIndicator); toolPanel.add(Box.createRigidArea(new Dimension(20, 15))); toolPanel.add(activeThreads); toolPanel.add(new JLabel(" / ")); toolPanel.add(totalThreads); toolPanel.add(Box.createRigidArea(new Dimension(10, 15))); toolPanel.add(runningIndicator); return toolPanel; }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
/** * adds a button to the button panel//from w ww . j a v a2 s .com * @param button */ private void addButtonToButtonPanel(JButton button) { button.setMinimumSize(new Dimension(90, 25)); button.setMaximumSize(new Dimension(160, 25)); buttonPanel.add(button); buttonPanel.add(Box.createRigidArea(new Dimension(0, 5))); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel constructButtons() { Box buttons = Box.createVerticalBox(); 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: ")); labelledSpinner.add(numFixations);// w w w. j a v a2s . com JButton recallButton = new JButton(new RecallAction(numFixations)); recallButton.setToolTipText("Scan shown scene and display results"); final JCheckBox showFixations = new JCheckBox("Show fixations", false); showFixations.setToolTipText("Show fixations for recalled scene"); showFixations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _sceneDisplay.setShowFixations(showFixations.isSelected()); } }); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(labelledSpinner); buttons.add(recallButton); buttons.add(Box.createRigidArea(new Dimension(0, 20))); buttons.add(showFixations); buttons.add(Box.createRigidArea(new Dimension(0, 20))); // TODO: There must be a better solution to this problem! JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(buttons, BorderLayout.NORTH); return panel; }
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
/** * The user has selected an option. Here we close and dispose the dialog. * If actionCommand is an ActionEvent, getCommandString() is called, * otherwise toString() is used to get the action command. * * @param actionCommand may be null/*ww w. jav a 2 s .c o m*/ */ private void registrationComponents() { Container contents = getContentPane(); contents.setLayout(new BorderLayout()); String title = Utils.getProperty("net.java.sip.communicator.gui.REG_WIN_TITLE"); if (title == null) title = "Registration Manager"; setTitle(title); setResizable(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { registrationDialogDone(CMD_CANCEL); } }); // Accessibility -- all frames, dialogs, and applets should // have a description getAccessibleContext().setAccessibleDescription("Registration Splash"); String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.REGISTRATION_PROMPT"); if (authPromptLabelValue == null) authPromptLabelValue = "Please fill in the following fields to register:"; JLabel splashLabel = new JLabel(authPromptLabelValue); splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); splashLabel.setHorizontalAlignment(SwingConstants.CENTER); splashLabel.setHorizontalTextPosition(SwingConstants.CENTER); contents.add(splashLabel, BorderLayout.NORTH); JPanel centerPane = new JPanel(); centerPane.setLayout(new GridBagLayout()); /* My additions */ nameTextField = new JTextField(); //needed below // name label nameLabel = new JLabel(); nameLabel.setLabelFor(nameTextField); String nLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.NAME_LABEL"); if (nLabelStr == null) nLabelStr = "Name"; nameLabel.setText(nLabelStr); int gridy = 0; GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(nameLabel, c); // name text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(nameTextField, c); lastNameTextField = new JTextField(); //needed below // last name label lastNameLabel = new JLabel(); lastNameLabel.setLabelFor(nameTextField); String lnLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.LAST_NAME_LABEL"); if (lnLabelStr == null) lnLabelStr = "Last Name"; lastNameLabel.setText(lnLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(lastNameLabel, c); // last name text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(lastNameTextField, c); mailTextField = new JTextField(); //needed below // mail label mailLabel = new JLabel(); mailLabel.setLabelFor(mailTextField); String mLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.MAIL_LABEL"); if (mLabelStr == null) mLabelStr = "Email"; mailLabel.setText(mLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(mailLabel, c); // mail text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(mailTextField, c); /* END: MY additions */ userNameTextField = new JTextField(); // needed below // user name label userNameLabel = new JLabel(); userNameLabel.setLabelFor(userNameTextField); String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL"); if (userNameLabelValue == null) userNameLabelValue = "Username"; userNameLabel.setText(userNameLabelValue); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(12, 12, 0, 0); centerPane.add(userNameLabel, c); // user name text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(12, 7, 0, 11); centerPane.add(userNameTextField, c); passwordTextField = new JPasswordField(); //needed below // password label passwordLabel = new JLabel(); passwordLabel.setLabelFor(passwordTextField); String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL"); if (pLabelStr == null) pLabelStr = "Password"; passwordLabel.setText(pLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(passwordLabel, c); // password text passwordTextField.setEchoChar('\u2022'); c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(passwordTextField, c); policyDropDown = new JComboBox(); policyDropDown.addItem("Basic"); policyDropDown.addItem("Pro"); policyDropDown.addItem("Enterprise"); // policy label policyLabel = new JLabel(); policyLabel.setLabelFor(policyDropDown); String plcLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.POLICY_LABEL"); if (plcLabelStr == null) plcLabelStr = "Policy"; policyLabel.setText(plcLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(policyLabel, c); // policy menu c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(policyDropDown, c); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, 0)); registerButton = new JButton(); registerButton.setMnemonic('G'); registerButton.setText("Register"); registerButton.setActionCommand(CMD_REGISTER); registerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { registrationDialogDone(event); } }); buttonPanel.add(registerButton); buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setActionCommand(CMD_CANCEL); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { registrationDialogDone(event); } }); buttonPanel.add(cancelButton); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 6; c.gridwidth = 2; c.insets = new Insets(11, 12, 11, 11); centerPane.add(buttonPanel, c); contents.add(centerPane, BorderLayout.CENTER); getRootPane().setDefaultButton(registerButton); registrationEqualizeButtonSizes(); setFocusTraversalPolicy(new FocusTraversalPol()); }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java
/** * Builds the panel hosting the components. * * @return See above.//from w ww.j ava 2 s .c o m */ private JPanel buildControlPanel() { JPanel controlPanel = new JPanel(); controlPanel.setBorder(null); controlPanel.add(cancelButton); controlPanel.add(Box.createRigidArea(H_SPACER_SIZE)); controlPanel.add(applyButton); controlPanel.add(Box.createRigidArea(H_SPACER_SIZE)); JPanel bar = new JPanel(); bar.setLayout(new BoxLayout(bar, BoxLayout.Y_AXIS)); bar.add(controlPanel); bar.add(Box.createVerticalStrut(10)); JPanel all = new JPanel(); all.setLayout(new BoxLayout(all, BoxLayout.X_AXIS)); all.add(UIUtilities.buildComponentPanel(menuButton)); all.add(UIUtilities.buildComponentPanelRight(bar)); return all; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** Builds and lays out the UI. */ private void buildGUI() { JPanel bars = new JPanel(), outerPanel = new JPanel(); bars.setBorder(null);/*from w w w .j a v a 2 s . c o m*/ bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS)); bars.add(createManagementBar()); if (!TreeViewerWin.JXTASKPANE_TYPE.equals(view.getLayoutType())) { bars.add(createSearchBar()); } outerPanel.setBorder(null); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(bars); outerPanel.add(Box.createRigidArea(HBOX)); outerPanel.add(Box.createHorizontalGlue()); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(UIUtilities.buildComponentPanel(outerPanel)); add(UIUtilities.buildComponentPanelRight(buildRightPane())); }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
private void setSliders() { if (sliderPanel != null) sliderPanel.removeAll();//from www. java 2 s . co m else sliderPanel = new JPanel(); JPanel rPanel = new JPanel(); // rPanel.setBackground(Color.blue); JPanel rPanel2 = new JPanel(); // rPanel2.setBackground(Color.green); rPanel.setAlignmentX(LEFT_ALIGNMENT); rPanel2.setAlignmentX(LEFT_ALIGNMENT); rSliders = new FloatTextField[numStocks]; //expected return JPanel matrixPanel = new JPanel(); matrixPanel.setAlignmentX(LEFT_ALIGNMENT); mSliders = new FloatTextField[15]; JPanel tPanel = new JPanel(); tPanel.setAlignmentX(LEFT_ALIGNMENT); // tPanel.setBackground(Color.blue); //tSlider = new ValueSliderFloat2("Tangency:", -0.5, 0.5, false); tSlider = new FloatTextField("Tangency:", t1_y, 0, 1); //tSlider.setPreferredSize(new Dimension(SLIDER_SIZE_X,45)); newMSlider(1, 0, tSlider, tPanel); //expected return rPanel.setLayout(new GridBagLayout()); rPanel.add(new JLabel("Expected Return:")); for (int i = 0; i < numStocks; i++) { rSliders[i] = new FloatTextField("E(R" + (i + 1) + ")", ExpectedReturn[i][0], -0.2, 0.2); rSliders[i].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45)); rSliders[i].setToolTipText("Adjusting the value of expected return for stock " + (i + 1) + "."); newMSlider(1, i, rSliders[i], rPanel); } ER_matrix = new Matrix(numStocks, 1, ExpectedReturn); // Covariance rPanel2.setLayout(new GridBagLayout()); rPanel2.add(new JLabel("Variance:")); for (int i = 0; i < numStocks; i++) { mSliders[i] = new FloatTextField("VAR(R" + (i + 1) + ")", COVR[i][i], 0.0, 0.2); mSliders[i].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45)); mSliders[i].setToolTipText("Adjusting the value of variance " + (i + 1) + "."); newMSlider(1, i, mSliders[i], rPanel2); } matrixPanel.setLayout(new GridBagLayout()); if (covarianceFlag) addRadioButton(0, 0, "Switch Input Matrix:", "Switch Input Matrix", switchArray, 0, matrixPanel, (ActionListener) this); else addRadioButton(0, 0, "Switch Input Matrix:", "Switch Input Matrix", switchArray, 1, matrixPanel, (ActionListener) this); switchedFlag = false; if (covarianceFlag) { // matrixPanel.add(new JLabel("Covariance Matrix:")); int k = numStocks; for (int i = 1; i < numStocks; i++) for (int j = 0; j < i; j++) { mSliders[k] = new FloatTextField("COV" + (i + 1) + (j + 1), COVR[i][j], -0.5, 0.5); mSliders[k].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45)); mSliders[k] .setToolTipText("Adjusting the value of correlation " + (i + 1) + "," + (j + 1) + "."); newMSlider(i, j, mSliders[k], matrixPanel); k++; } } else { // matrixPanel.add(new JLabel("Correlation Matrix:")); int k = numStocks; for (int i = 1; i < numStocks; i++) for (int j = 0; j < i; j++) { mSliders[k] = new FloatTextField("CORR" + (i + 1) + (j + 1), CORR[i][j], -0.5, 0.5); mSliders[k].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45)); mSliders[k] .setToolTipText("Adjusting the value of correlation " + (i + 1) + "," + (j + 1) + "."); newMSlider(i, j, mSliders[k], matrixPanel); if (CORR[i][j] > 1) System.out.println("setting slider CORR[" + i + "][" + j + "]=" + CORR[i][j]); k++; } } try { CORR = covr2corr(COVR, ExpectedReturn, numStocks); } catch (Exception e) { System.out.println("corrlation out of range."); } covr_matrix = new Matrix(numStocks, numStocks, COVR); corr_matrix = new Matrix(numStocks, numStocks, CORR); sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.PAGE_AXIS)); /*Box box = Box.createVerticalBox(); box.add(rPanel); box.add(rPanel2); box.add(new JLabel("Correlation Matrix:")); box.add(matrixPanel); sliderPanel.add(box);*/ //sliderPanel.setBackground(Color.red); matrixPanel.validate(); sliderPanel.add(rPanel); sliderPanel.add(rPanel2); sliderPanel.add(Box.createRigidArea(new Dimension(0, 5))); sliderPanel.add(matrixPanel); sliderPanel.add(tPanel); sliderPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); sliderPanel.validate(); //sliderPanel.setBackground(Color.white); }
From source file:org.docx4all.ui.main.WordMLEditor.java
JMenuBar createMenuBar() { JMenuBar menubar = new JMenuBar(); JMenu fileMenu = FileMenu.getInstance().createJMenu(); JMenu editMenu = EditMenu.getInstance().createJMenu(); JMenu formatMenu = FormatMenu.getInstance().createJMenu(); JMenu hyperlinkMenu = HyperlinkMenu.getInstance().createJMenu(); JMenu contentControlMenu = ContentControlMenu.getInstance().createJMenu(); JMenu reviewMenu = ReviewMenu.getInstance().createJMenu(); JMenu viewMenu = ViewMenu.getInstance().createJMenu(); JMenu plutextMenu = PlutextMenu.getInstance().createJMenu(); JMenu windowMenu = WindowMenu.getInstance().createJMenu(); JMenu helpMenu = HelpMenu.getInstance().createJMenu(); menubar.add(fileMenu);//from w w w . java2 s.c o m menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(editMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(formatMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(hyperlinkMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(contentControlMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(reviewMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(viewMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(plutextMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(windowMenu); menubar.add(Box.createRigidArea(new Dimension(12, 0))); menubar.add(helpMenu); return menubar; }
From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java
/** * Initializes the selectionPanel://ww w . jav a 2s .co m * Fills one combobox with all transitions and places of the used Petri net, * and one combobox with only transitions. * Initially nothing is selected in both comboboxes and the second combobox * is disabled. */ private void initializeSelection() { sb1 = new JComboBox(); sb1.setMaximumSize(new Dimension(200, 20)); //SteppedComboBoxUI allows the pop-up menu to be of different width //than the width of the combobox, here sb1, itself sb1.setUI(new SteppedComboBoxUI()); sb1.setBorder(BorderFactory.createEtchedBorder()); sb2 = new JComboBox(); sb2.setUI(new SteppedComboBoxUI()); sb2.setMaximumSize(new Dimension(200, 20)); sb2.setBorder(BorderFactory.createEtchedBorder()); //Fill the boxes sb1.addItem("-------------"); sb2.addItem("-------------"); //add all places of the Petri net to the first selection box Iterator it = extendedPetriNet.getPlaces().iterator(); while (it.hasNext()) { Element current = (Element) it.next(); ExtendedPlace ep = (ExtendedPlace) current; String placeString = "Place - " + ep.getIdentifier(); sb1.addItem(placeString); if (boxMap.get(placeString) == null) { //and add the place to the boxMap if it is not already in it boxMap.put(placeString, current); } } //add all transitions of the Petri net to both selection boxes Iterator dit = extendedPetriNet.getTransitions().iterator(); while (dit.hasNext()) { Element current = (Element) dit.next(); ExtendedTransition et = (ExtendedTransition) current; try { String transString = "Transition - " + et.getLogEvent().getModelElementName() + " " + et.getLogEvent().getEventType(); if (boxMap.get(transString) == null) { //place transition in sb1 & sb2 sb1.addItem(transString); sb2.addItem(transString); //and add the transition to the boxMap boxMap.put(transString, current); } else { //at least one transition with the same name within the boxMap //count the number of transitions in the boxMap having this same name Iterator keys = boxMap.keySet().iterator(); int number = 0; while (keys.hasNext()) { String key = (String) keys.next(); if (key.startsWith(transString)) { number++; } } //add current transition to the boxMap, with between brackets //its number (>=1) transString = "Transition - " + et.getLogEvent().getModelElementName() + " (" + number + ") " + " " + et.getLogEvent().getEventType(); //place transition in sb1 & sb2 sb1.addItem(transString); sb2.addItem(transString); boxMap.put(transString, current); } } catch (NullPointerException ne) { /* Invisible transitions do not have a ModelElementName or EventType, thus an exception occurs. It is caught here */ } } //place objects on the selectionPanel selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.Y_AXIS)); selectionPanel.add(Box.createRigidArea(new Dimension(15, 10))); selectLabel.setFont(new Font("SansSerif", Font.BOLD, 14)); selectionPanel.add(selectLabel); selectionPanel.add(Box.createRigidArea(new Dimension(5, 5))); selectionPanel.add(sb1); selectionPanel.add(Box.createRigidArea(new Dimension(5, 10))); andLabel.setForeground(Color.GRAY); selectionPanel.add(andLabel); selectionPanel.add(Box.createRigidArea(new Dimension(5, 5))); sb1.setBackground(Color.white); sb2.setBackground(Color.white); sb2.setEnabled(false); selectionPanel.add(sb2); selectionPanel.setBackground(new Color(220, 220, 220)); selectLabel.setAlignmentX(LEFT_ALIGNMENT); sb1.setAlignmentX(LEFT_ALIGNMENT); andLabel.setAlignmentX(LEFT_ALIGNMENT); sb2.setAlignmentX(LEFT_ALIGNMENT); selectionPanel.setBorder(BorderFactory.createEtchedBorder()); selectionPanel.setPreferredSize(new Dimension(240, 140)); selectionPanel.setMinimumSize(new Dimension(240, 140)); }