List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:org.jdal.swing.TableEditor.java
/** * @return header//from w w w . java 2s . c om */ protected Container createHeader() { JLabel label = new JLabel(getName()); label.setAlignmentX(Container.LEFT_ALIGNMENT); Box box = Box.createHorizontalBox(); box.add(label); return box; }
From source file:org.kepler.gui.DialogGeneralTab.java
/** * getTopPanel//from ww w . j ava2 s. c o m * * @return Component */ protected Component getTopPanel() { Box topPanel = Box.createHorizontalBox(); JLabel nameLbl = WidgetFactory.makeJLabel( StaticResources.getDisplayString("dialogs." + _targetType + ".general.name", ""), TabbedDialog.jLabelDims); topPanel.add(nameLbl); nameTxtFld = WidgetFactory.makeJTextField((_target != null ? _target.getName() : ""), TabbedDialog.textFieldDims); topPanel.add(nameTxtFld); JLabel idLbl = WidgetFactory.makeJLabel( StaticResources.getDisplayString("dialogs." + _targetType + ".general.id", ""), TabbedDialog.idLabelDims); idLbl.setHorizontalAlignment(SwingConstants.RIGHT); topPanel.add(idLbl); topPanel.add(WidgetFactory.getDefaultSpacer()); JLabel idFieldLbl = WidgetFactory.makeJLabel(getLSIDString(_target), TabbedDialog.idValueDims); topPanel.add(idFieldLbl); topPanel.add(Box.createHorizontalGlue()); return topPanel; }
From source file:org.stanwood.swing.AboutDialog.java
private void createTitleArea(Box box, String title, String version) { JLabel lblTitle = new JLabel(title); lblTitle.setHorizontalTextPosition(JLabel.LEFT); lblTitle.setHorizontalAlignment(JLabel.LEFT); lblTitle.setFont(new Font("Serif", Font.BOLD, 24)); box.add(lblTitle); JLabel lblVersion = new JLabel(version); lblVersion.setFont(new Font("Serif", Font.BOLD, 12)); lblVersion.setHorizontalAlignment(JLabel.LEFT); lblVersion.setHorizontalTextPosition(JLabel.LEFT); box.add(lblVersion);//w ww .ja v a 2s. co m }
From source file:fll.scheduler.ChooseChallengeDescriptor.java
private void initComponents() { getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1;//from www.j ava 2 s .co m gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; final JTextArea instructions = new JTextArea( "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.", 3, 40); instructions.setEditable(false); instructions.setWrapStyleWord(true); instructions.setLineWrap(true); getContentPane().add(instructions, gbc); gbc = new GridBagConstraints(); mCombo = new JComboBox<DescriptionInfo>(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(mCombo, gbc); mCombo.setRenderer(new DescriptionInfoRenderer()); mCombo.setEditable(false); final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo(); for (final DescriptionInfo info : descriptions) { mCombo.addItem(info); } mFileField = new JLabel(); gbc = new GridBagConstraints(); gbc.weightx = 1; getContentPane().add(mFileField, gbc); final JButton chooseButton = new JButton("Choose File"); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(chooseButton, gbc); chooseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mFileField.setText(null); final JFileChooser fileChooser = new JFileChooser(); final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" }); fileChooser.setFileFilter(filter); final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selectedFile = fileChooser.getSelectedFile(); mFileField.setText(selectedFile.getAbsolutePath()); } } }); final Box buttonPanel = new Box(BoxLayout.X_AXIS); gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; getContentPane().add(buttonPanel, gbc); buttonPanel.add(Box.createHorizontalGlue()); final JButton ok = new JButton("Ok"); buttonPanel.add(ok); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { // use the selected description if nothing is entered in the file box final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex()); if (null != descriptionInfo) { mSelected = descriptionInfo.getURL(); } final String text = mFileField.getText(); if (!StringUtils.isEmpty(text)) { final File file = new File(text); if (file.exists()) { try { mSelected = file.toURI().toURL(); } catch (final MalformedURLException e) { throw new FLLInternalException("Can't turn file into URL?", e); } } } setVisible(false); } }); final JButton cancel = new JButton("Cancel"); buttonPanel.add(cancel); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent ae) { mSelected = null; setVisible(false); } }); pack(); }
From source file:com.orange.atk.graphAnalyser.RealtimeGraph.java
private void initComponents() { jListGraph = new JList(listModelGraph); jPanelroot = new JPanel(); jScrollPaneListGraph = new JScrollPane(); jListPerfGraph = new JList(listModelGraph); jComboBoxLeft = new JComboBox(comboModelLeft); jComboBoxRight = new JComboBox(comboModelRight); setDefaultCloseOperation(DISPOSE_ON_CLOSE); jScrollPaneListGraph.setViewportView(jListPerfGraph); jComboBoxLeft.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxLeftActionPerformed(evt); }/*w w w .ja v a 2s . com*/ }); jComboBoxRight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxRightActionPerformed(evt); } }); jPanelroot.setLayout(new BorderLayout()); jPanelroot.add(chartPanel, BorderLayout.CENTER); toolPane = new JPanel(); toolPane.setLayout(new FlowLayout()); toolPane.add(jComboBoxLeft); Box graphlistbox = Box.createVerticalBox(); graphlistbox.add(new JLabel("List of Graph")); graphlistbox.add(jScrollPaneListGraph); toolPane.add(graphlistbox); toolPane.add(jComboBoxRight); jPanelroot.add(toolPane, BorderLayout.NORTH); setContentPane(jPanelroot); //a small size for small screen // setMaximumSize(new Dimension(600,500)); pack(); }
From source file:org.jcurl.demo.tactics.CurlerSwingBean.java
public CurlerSwingBean() { setLayout(new BorderLayout()); final Box b = Box.createVerticalBox(); {/* w ww. java2 s . c om*/ final JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.setBorder(BorderFactory.createTitledBorder("Curl Model")); p.add(curlers = new JComboBox(findCurlers())); b.add(p); } { final JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(BorderFactory.createTitledBorder("Draw-To-Tee")); { time = new JSpinnerNumberUnit(); time.setLabel("time: "); time.setBase(Unit.SECOND); time.setModel(new SpinnerNumberModel(24.0, 17.0, 28.0, 0.1)); time.addPropertyChangeListener(this); time.addChangeListener(this); p.add(time); } { curl = new JSpinnerNumberUnit(); curl.setLabel("curl: "); curl.setBase(Unit.METER); curl.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER); curl.setModel(new SpinnerNumberModel(1.0, 0.0, 3.0, 0.1)); curl.addPropertyChangeListener(this); curl.addChangeListener(this); p.add(curl); } b.add(p); } add(b, BorderLayout.NORTH); add(new JLabel("TODO: other settings"), BorderLayout.CENTER); setEnabled(false); }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;//from w w w. ja va 2 s . c o m height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:org.jdal.swing.TableEditor.java
/** * Creates a new Box with table and actions buttons * @return a new Box/*from ww w .j a va 2s .c o m*/ */ protected Container createTablePanel() { table = new JTable(tableModel, tableModel.getTableColumnModel()); table.setRowHeight(22); table.setAutoCreateRowSorter(true); tableModel.addTableModelListener(this); JScrollPane scroll = new JScrollPane(table); scroll.setAlignmentX(Container.LEFT_ALIGNMENT); Box box = Box.createVerticalBox(); JButton addButton = new JButton(new AddAction()); JButton deleteButton = new JButton(new DeleteAction()); JButton saveButton = new JButton(new SaveAction()); JButton refreshButton = new JButton(new RefreshAction()); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(addButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(deleteButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(saveButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(refreshButton); buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT); buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25)); box.add(buttonBox); box.add(Box.createVerticalStrut(5)); box.add(scroll); return box; }
From source file:common.AbstractGUI.java
protected void createLogPanel() { logPanel = new JPanel(); logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.Y_AXIS)); logTextArea = new JTextArea(33, 30); logTextArea.setEditable(false);//from w w w . j ava 2 s.c o m logTextArea.setAutoscrolls(true); logTextArea.setFont(new Font("Courier New", Font.PLAIN, 11)); logTextArea.setBackground(Color.DARK_GRAY); logTextArea.setForeground(Color.GREEN); logTextArea.addMouseListener(logTextAreaMouseListener); scrollPane = new JScrollPane(logTextArea); Box horizontalLayout = Box.createHorizontalBox(); filterTxt = new JTextField(); filterBtn = new JButton("Filter"); filterBtn.addActionListener(filterActionListner); filterTxt.setMaximumSize(new Dimension(250, 30)); horizontalLayout.add(filterTxt); horizontalLayout.add(filterBtn); logPanel.add(horizontalLayout); logPanel.add(scrollPane); tabbedPane.addTab("Log", logPanel); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.IntHistogramVisualizer.java
@Override protected JComponent addSettingsPanels(JTabbedPane aPanel) { addTab(aPanel, Messages.DI_GENERAL, new SettingsPanel(general), Messages.TT_GENSETTINGS); addTab(aPanel, Messages.DI_AXES, new SettingsPanel(settings.axes), Messages.TT_AXESSETTINGS); addTab(aPanel, Messages.DI_GRID, new SettingsPanel(settings.grid), Messages.TT_GRIDSETTINGS); boolean useScatter = settings.useScatter(); final Box histPanel = Box.createVerticalBox(); final JComboBox choiceCombo = addChoice(histPanel, useScatter ? 1 : 0); final CardLayout innerLayout = new CardLayout(); final JPanel innerPanel = new JPanel(innerLayout); histPanel.add(innerPanel); aPanel.addTab(Messages.DI_HISTOGRAM, null, histPanel, Messages.TT_HISTSETTINGS); ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { innerLayout.next(innerPanel); }// w w w . j av a 2 s. c o m } }; choiceCombo.addItemListener(listener); innerPanel.add(new SettingsPanel(settings.bars), "0"); innerPanel.add(new SettingsPanel(settings.scatter), "1"); if (useScatter) { innerLayout.next(innerPanel); } return choiceCombo; }