List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:MainClass.java
public MainClass() { JToggleButton tog = new JToggleButton("ToggleButton"); JCheckBox cb = new JCheckBox("CheckBox"); JRadioButton radio = new JRadioButton("RadioButton"); SimpleListener sl = new SimpleListener(); tog.addActionListener(sl);/* ww w .j a v a 2 s .com*/ cb.addActionListener(sl); radio.addActionListener(sl); Box buttonBox = new Box(BoxLayout.Y_AXIS); buttonBox.add(tog); buttonBox.add(cb); buttonBox.add(radio); undoButton.setEnabled(false); redoButton.setEnabled(false); undoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.undo(); } catch (CannotUndoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); redoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.redo(); } catch (CannotRedoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); Box undoRedoBox = new Box(BoxLayout.X_AXIS); undoRedoBox.add(Box.createGlue()); undoRedoBox.add(undoButton); undoRedoBox.add(Box.createHorizontalStrut(2)); undoRedoBox.add(redoButton); undoRedoBox.add(Box.createGlue()); Container content = getContentPane(); content.setLayout(new BorderLayout()); content.add(buttonBox, BorderLayout.CENTER); content.add(undoRedoBox, BorderLayout.SOUTH); setSize(400, 150); }
From source file:be.fedict.eid.tsl.Pkcs11CallbackHandler.java
private char[] getPin() { Box mainPanel = Box.createVerticalBox(); Box passwordPanel = Box.createHorizontalBox(); JLabel promptLabel = new JLabel("eID PIN:"); passwordPanel.add(promptLabel); passwordPanel.add(Box.createHorizontalStrut(5)); JPasswordField passwordField = new JPasswordField(8); passwordPanel.add(passwordField);//from w w w . j a v a 2 s.c o m mainPanel.add(passwordPanel); Component parentComponent = null; int result = JOptionPane.showOptionDialog(parentComponent, mainPanel, "eID PIN?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (result == JOptionPane.OK_OPTION) { char[] pin = passwordField.getPassword(); return pin; } throw new RuntimeException("operation canceled."); }
From source file:com.diversityarrays.util.DatePickerDialog.java
public DatePickerDialog(Window owner, String title, Closure<Date> onComplete) { super(owner, title, ModalityType.APPLICATION_MODAL); this.onComplete = onComplete; datePicker.getMonthView().setZoomable(true); datePicker.setLinkPanel(null);/*from ww w.j av a2s . co m*/ datePicker.setFormats(getDefaultDateFormats()); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(cancel)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(save)); buttons.add(Box.createHorizontalGlue()); Container cp = getContentPane(); cp.add(datePicker.getMonthView(), BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:edu.stanford.smi.protegex.owl.ui.widget.HTMLEditorPanel.java
public HTMLEditorPanel(OWLModel owlModel, String text, String language) { setLayout(new BorderLayout()); ekitCore = new EkitCore(null, null, null, null, false, true, true, null, null, false, false); ekitCore.setDocumentText(text);//from www . j a v a 2 s . c o m JPanel ekitTopPanel = new JPanel(); ekitTopPanel.setLayout(new GridLayout(2, 1)); ekitTopPanel.add(ekitCore.getMenuBar()); ekitTopPanel.add(ekitCore.getToolBar(true)); if (owlModel != null) { languageComboBox = ComponentUtil.createLanguageComboBox(owlModel, language); Box languagePanel = Box.createHorizontalBox(); languagePanel.add(new JLabel("Language: ")); languagePanel.add(languageComboBox); add(BorderLayout.SOUTH, languagePanel); } add(BorderLayout.NORTH, ekitTopPanel); add(BorderLayout.CENTER, ekitCore); }
From source file:UndoableToggleApp2.java
public UndoableToggleApp2() { JToggleButton tog = new JToggleButton("ToggleButton"); JCheckBox cb = new JCheckBox("CompoundEdit ExampleCheckBox"); JRadioButton radio = new JRadioButton("RadioButton"); SimpleListener sl = new SimpleListener(); tog.addActionListener(sl);/*from w w w. j av a2 s. com*/ cb.addActionListener(sl); radio.addActionListener(sl); Box buttonBox = new Box(BoxLayout.Y_AXIS); buttonBox.add(tog); buttonBox.add(cb); buttonBox.add(radio); undoButton.setEnabled(false); redoButton.setEnabled(false); endButton.setEnabled(false); undoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.undo(); } catch (CannotUndoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); redoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.redo(); } catch (CannotRedoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); endButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { edit.end(); endButton.setEnabled(false); undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } }); Box undoRedoEndBox = new Box(BoxLayout.X_AXIS); undoRedoEndBox.add(Box.createGlue()); undoRedoEndBox.add(undoButton); undoRedoEndBox.add(Box.createHorizontalStrut(2)); undoRedoEndBox.add(redoButton); undoRedoEndBox.add(Box.createHorizontalStrut(2)); undoRedoEndBox.add(endButton); undoRedoEndBox.add(Box.createGlue()); Container content = getContentPane(); content.setLayout(new BorderLayout()); content.add(buttonBox, BorderLayout.CENTER); content.add(undoRedoEndBox, BorderLayout.SOUTH); setSize(400, 150); }
From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { Box ret = new Box(BoxLayout.X_AXIS); ret.add(new JLabel("k:")); final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1)); spin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setK(((Number) spin.getValue()).intValue()); v.settingsChanged(false);/*from w w w .ja v a2 s . com*/ } }); ret.add(spin); final JCheckBox showClustersBox = new JCheckBox("Color clusters"); ret.add(showClustersBox); showClustersBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { showClusters = showClustersBox.isSelected(); v.settingsChanged(false); } }); return ret; }
From source file:com.diversityarrays.wizard.WizardRunner.java
protected void handleWizardEnded(WizardEndedReason reason) { if (handler != null) { handler.execute(reason);/*from w w w.java2 s .c o m*/ } status.setText(reason.toString()); WizardRunner.this.setEnabled(false); RootPaneContainer rpc = ((RootPaneContainer) window); rpc.getContentPane().remove(this); Container cp = rpc.getContentPane(); cp.removeAll(); JLabel label = new JLabel(reason.toString()); Box n = Box.createHorizontalBox(); n.add(Box.createHorizontalGlue()); n.add(label); n.add(Box.createHorizontalGlue()); cp.add(n, BorderLayout.CENTER); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(new JButton(closeMe)); box.add(Box.createHorizontalStrut(20)); cp.add(box, BorderLayout.SOUTH); cp.setBackground(Color.LIGHT_GRAY); Dimension d = window.getSize(); ++d.width; window.setSize(d); }
From source file:org.porphyry.view.Opener.java
protected void display(Component c, String side) { Box panel = (JSplitPane.RIGHT.equals(side)) ? this.rightPanel : this.leftPanel; panel.add(c); }
From source file:UndoableToggleApp.java
public UndoableToggleApp() { // Create some toggle buttons (and subclasses) JToggleButton tog = new JToggleButton("ToggleButton"); JCheckBox cb = new JCheckBox("CheckBox"); JRadioButton radio = new JRadioButton("RadioButton"); // Add our listener to each toggle button SimpleListener sl = new SimpleListener(); tog.addActionListener(sl);/*ww w . ja v a 2s . c o m*/ cb.addActionListener(sl); radio.addActionListener(sl); // Layout the buttons Box buttonBox = new Box(BoxLayout.Y_AXIS); buttonBox.add(tog); buttonBox.add(cb); buttonBox.add(radio); // Create undo and redo buttons (initially disabled) undoButton = new JButton("Undo"); redoButton = new JButton("Redo"); undoButton.setEnabled(false); redoButton.setEnabled(false); // Add a listener to the undo button. It attempts to call undo() on the // current edit, then enables/disables the undo/redo buttons as // appropriate. undoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.undo(); } catch (CannotUndoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); // Add a redo listener: just like the undo listener, but for redo this // time. redoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { edit.redo(); } catch (CannotRedoException ex) { ex.printStackTrace(); } finally { undoButton.setEnabled(edit.canUndo()); redoButton.setEnabled(edit.canRedo()); } } }); // Layout the undo/redo buttons Box undoRedoBox = new Box(BoxLayout.X_AXIS); undoRedoBox.add(Box.createGlue()); undoRedoBox.add(undoButton); undoRedoBox.add(Box.createHorizontalStrut(2)); undoRedoBox.add(redoButton); undoRedoBox.add(Box.createGlue()); // Layout the main frame Container content = getContentPane(); content.setLayout(new BorderLayout()); content.add(buttonBox, BorderLayout.CENTER); content.add(undoRedoBox, BorderLayout.SOUTH); setSize(400, 150); }
From source file:org.colombbus.tangara.update.SoftwareUpdateDialog.java
private void addButtonPane() { Box box = Box.createHorizontalBox(); box.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); box.add(Box.createGlue()); String closeLabel = bundle.getString("SoftwareUpdateDialog.close"); //$NON-NLS-1$ closeButton = new JButton(closeLabel); closeButton.addActionListener(this); box.add(closeButton);// w w w. j a v a 2 s . c om add(box, BorderLayout.SOUTH); }