public ActionBar(View view, boolean temp) { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.view = view; this.temp = temp; add(Box.createHorizontalStrut(2)); JLabel label = new JLabel(jEdit.getProperty("view.action.prompt")); add(label); add(Box.createHorizontalStrut(12)); add(action = new ActionTextField()); action.setEnterAddsToHistory(false); Dimension max = action.getPreferredSize(); max.width = Integer.MAX_VALUE; action.setMaximumSize(max); action.addActionListener(new ActionHandler()); action.getDocument().addDocumentListener(new DocumentHandler()); if (temp) { close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif")); close.addActionListener(new ActionHandler()); close.setToolTipText(jEdit.getProperty("view.action.close-tooltip")); add(close); } this.temp = temp; }
/** * Creates a dialog that is showing the histogram for the given node (if null one is selected for * you) */ private JPanel createNormalityTestDialog(Node selected) { DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel(); QQPlot qqPlot = new QQPlot(dataSet, selected); NormalityTestEditorPanel editorPanel = new NormalityTestEditorPanel(qqPlot, dataSet); JTextArea display = new JTextArea( NormalityTests.runNormalityTests( dataSet, (ContinuousVariable) qqPlot.getSelectedVariable()), 20, 65); display.setEditable(false); editorPanel.addPropertyChangeListener(new NormalityTestListener(display)); Box box = Box.createHorizontalBox(); box.add(display); box.add(Box.createHorizontalStrut(3)); box.add(editorPanel); box.add(Box.createHorizontalStrut(5)); box.add(Box.createHorizontalGlue()); Box vBox = Box.createVerticalBox(); vBox.add(Box.createVerticalStrut(15)); vBox.add(box); vBox.add(Box.createVerticalStrut(5)); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(vBox, BorderLayout.CENTER); return panel; }
public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
public PaymentPanel(final CreditCardService cardService) { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(new JLabel("Credit Card")); add(Box.createHorizontalStrut(5)); final JTextField creditCard = new JTextField(30); add(creditCard); add(Box.createHorizontalStrut(5)); JButton purchase = new JButton("Purchase"); purchase.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { double total = cartTableModel.getTotal(); String cardNumber = creditCard.getText(); String confirmation = "Do you want to charge " + total + " to your " + cardNumber + " card?"; String title = "Confirm charge"; int confirm = JOptionPane.showConfirmDialog( PaymentPanel.this, confirmation, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.YES_OPTION) { CreditCard card = new CreditCard(cardNumber); cardService.debit(card, total); } } }); add(Box.createHorizontalStrut(5)); add(purchase); }
public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
private void createMarginBox(Container c, Component comp) { c.add(Box.createVerticalStrut(10)); Box lrMargins = Box.createHorizontalBox(); lrMargins.add(Box.createHorizontalStrut(10)); lrMargins.add(comp); lrMargins.add(Box.createHorizontalStrut(10)); c.add(lrMargins); c.add(Box.createVerticalStrut(10)); }
// Center given button in a box, centered vertically and 6 pixels on left and right private Box createBoxForButton(JButton button) { Box buttonRow = Box.createHorizontalBox(); buttonRow.add(Box.createHorizontalStrut(6)); buttonRow.add(button); buttonRow.add(Box.createHorizontalStrut(6)); Box buttonBox = Box.createVerticalBox(); buttonBox.add(Box.createVerticalGlue()); buttonBox.add(buttonRow); buttonBox.add(Box.createVerticalGlue()); return buttonBox; }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
// {{{ init() method private void init() { EditBus.addToBus(this); /* Setup panes */ JPanel content = new JPanel(new BorderLayout(12, 12)); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); tabPane = new JTabbedPane(); tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this)); tabPane.addTab( jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true)); tabPane.addTab( jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false)); EditBus.addToBus(installer); content.add(BorderLayout.CENTER, tabPane); tabPane.addChangeListener(new ListUpdater()); /* Create the buttons */ Box buttons = new Box(BoxLayout.X_AXIS); ActionListener al = new ActionHandler(); mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options")); mgrOptions.addActionListener(al); pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options")); pluginOptions.addActionListener(al); done = new JButton(jEdit.getProperty("plugin-manager.done")); done.addActionListener(al); buttons.add(Box.createGlue()); buttons.add(mgrOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(pluginOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(done); buttons.add(Box.createGlue()); getRootPane().setDefaultButton(done); content.add(BorderLayout.SOUTH, buttons); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setIconImage(GUIUtilities.getPluginIcon()); pack(); GUIUtilities.loadGeometry(this, parent, "plugin-manager"); GUIUtilities.addSizeSaver(this, parent, "plugin-manager"); setVisible(true); } // }}}
/** * Constructor of class Wizard * * @param parent the parent frame * @param name the title of the dialog * @param modal whether the dialog should be modal */ public Wizard(JFrame parent, String name, boolean modal) { super(parent, name, modal); // Code inspired by http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/ listeners = new LinkedList<WizardListener>(); returnCode = -1; this.parent = parent; panelMap = new HashMap<Object, WizardPanel>(); panels = new Vector<WizardPanel>(); firstPanel = null; currentPanel = null; handler = new EventHandler(); // Create the main panel JPanel buttonPanel = new JPanel(); Box buttonBox = new Box(BoxLayout.X_AXIS); cardPanel = new JPanel(); cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); cardLayout = new CardLayout(); cardPanel.setLayout(cardLayout); backButton = new JButton("Back"); nextButton = new JButton("Next"); cancelButton = new JButton("Cancel"); backButton.addActionListener(handler); nextButton.addActionListener(handler); cancelButton.addActionListener(handler); backButton.setEnabled(false); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(new JSeparator(), BorderLayout.NORTH); buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); buttonBox.add(backButton); buttonBox.add(Box.createHorizontalStrut(10)); buttonBox.add(nextButton); buttonBox.add(Box.createHorizontalStrut(30)); buttonBox.add(cancelButton); buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER); pack(); }
protected void initComponents() { int border = 2; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // Description label JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0)); descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); String text = thread.getRetrievable().getName(); text = text.length() > 40 ? text.substring(0, 37) + "..." : text; descriptionLabel = new JLabel(text); descriptionPanel.add(descriptionLabel); this.add(descriptionPanel); // Progrees and cancel button JPanel progressPanel = new JPanel(); progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS)); progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); progressBar = new JProgressBar(0, 100); progressBar.setPreferredSize(new Dimension(100, 16)); progressPanel.add(progressBar); progressPanel.add(Box.createHorizontalStrut(8)); cancelButton = new JButton("Cancel"); cancelButton.setBackground(Color.RED); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { cancelButtonActionPerformed(event); } }); progressPanel.add(cancelButton); this.add(progressPanel); }
private MainPanel() { super(new BorderLayout()); StringBuffer buf = new StringBuffer(); for (int i = 0; i < 100; i++) { String s = i + LF; buf.append(s); } final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString())); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); JSpinner spinner = new JSpinner( new SpinnerNumberModel( scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1)); spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0")); spinner.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner s = (JSpinner) e.getSource(); scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue()); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("Unit Increment:")); box.add(Box.createHorizontalStrut(2)); box.add(spinner); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(box, BorderLayout.NORTH); add(scrollPane); setPreferredSize(new Dimension(320, 240)); }
private Component createOptionsPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); hideButton = new JButton( new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { hideSelected(); } }); showButton = new JButton( new AbstractAction("Show") { public void actionPerformed(ActionEvent e) { showSelected(); } }); panel.add(showButton); panel.add(Box.createHorizontalStrut(10)); panel.add(hideButton); panel.add(Box.createHorizontalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); return panel; }
public LibraryManagerUI(Frame parent, Platform platform) { super(parent, "Library Manager", Dialog.ModalityType.APPLICATION_MODAL, _("Unable to reach Arduino.cc due to possible network issues.")); this.platform = platform; filtersContainer.add(new JLabel(_("Topic")), 1); filtersContainer.remove(2); typeChooser = new JComboBox(); typeChooser.setMaximumRowCount(20); typeChooser.setEnabled(false); filtersContainer.add(Box.createHorizontalStrut(5), 0); filtersContainer.add(new JLabel(_("Type")), 1); filtersContainer.add(Box.createHorizontalStrut(5), 2); filtersContainer.add(typeChooser, 3); }
private JComponent createAddPrefixComponent(final SourceFolder folder) { final IconActionComponent iconComponent = new IconActionComponent( ADD_PREFIX_ICON, ADD_PREFIX_ROLLOVER_ICON, ProjectBundle.message("module.paths.package.prefix.tooltip"), new Runnable() { public void run() { final String message = ProjectBundle.message( "module.paths.package.prefix.prompt", toRelativeDisplayPath(folder.getUrl(), getContentEntry().getUrl() + ":")); final String prefix = Messages.showInputDialog( JavaContentRootPanel.this, message, ProjectBundle.message("module.paths.package.prefix.title"), Messages.getQuestionIcon(), folder.getPackagePrefix(), null); if (prefix != null) { myCallback.setPackagePrefix(folder, prefix); } } }); final JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); panel.add(iconComponent, BorderLayout.CENTER); panel.add(Box.createHorizontalStrut(3), BorderLayout.EAST); return panel; }
private JPanel createToolPanel() { configurationOverrideCombo.setModel(configurationOverrideModel); final int preferredHeight = configurationOverrideCombo.getPreferredSize().height; configurationOverrideCombo.setPreferredSize(new Dimension(250, preferredHeight)); configurationOverrideCombo.setMaximumSize(new Dimension(350, preferredHeight)); treeModel = new ResultTreeModel(); resultsTree = new Tree(treeModel); resultsTree.setRootVisible(false); final TreeSelectionListener treeSelectionListener = new ToolWindowSelectionListener(); resultsTree.addTreeSelectionListener(treeSelectionListener); final MouseListener treeMouseListener = new ToolWindowMouseListener(); resultsTree.addMouseListener(treeMouseListener); resultsTree.setCellRenderer(new ResultTreeRenderer()); progressLabel = new JLabel(" "); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setMinimum(0); final Dimension progressBarSize = new Dimension(100, progressBar.getPreferredSize().height); progressBar.setMinimumSize(progressBarSize); progressBar.setPreferredSize(progressBarSize); progressBar.setMaximumSize(progressBarSize); progressPanel = new JToolBar(JToolBar.HORIZONTAL); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(new JLabel(CheckStyleBundle.message("plugin.toolwindow.override"))); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(configurationOverrideCombo); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.addSeparator(); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(progressLabel); progressPanel.add(Box.createHorizontalGlue()); progressPanel.setFloatable(false); progressPanel.setBackground(UIManager.getColor("Panel.background")); progressPanel.setBorder(null); final JPanel toolPanel = new JPanel(new BorderLayout()); toolPanel.add(new JBScrollPane(resultsTree), BorderLayout.CENTER); toolPanel.add(progressPanel, BorderLayout.NORTH); ToolTipManager.sharedInstance().registerComponent(resultsTree); return toolPanel; }
/** Performs the action of loading a session from a file. */ public void actionPerformed(ActionEvent e) { DataModel dataModel = getDataEditor().getSelectedDataModel(); if (!(dataModel instanceof DataSet)) { JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set."); return; } this.dataSet = (DataSet) dataModel; SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1); JSpinner jSpinner = new JSpinner(spinnerNumberModel); jSpinner.setPreferredSize(jSpinner.getPreferredSize()); spinnerNumberModel.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SpinnerNumberModel model = (SpinnerNumberModel) e.getSource(); setNumLags(model.getNumber().intValue()); } }); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Number of time lags: ")); b1.add(Box.createHorizontalGlue()); b1.add(Box.createHorizontalStrut(15)); b1.add(jSpinner); b1.setBorder(new EmptyBorder(10, 10, 10, 10)); b.add(b1); panel.add(b, BorderLayout.CENTER); EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true); DesktopController.getInstance().addEditorWindow(editorWindow); editorWindow.setVisible(true); editorWindow.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosed(InternalFrameEvent e) { EditorWindow window = (EditorWindow) e.getSource(); if (!window.isCanceled()) { if (dataSet.isContinuous()) { createContinuousTimeSeriesData(); } else if (dataSet.isDiscrete()) { createDiscreteTimeSeriesData(); } else { JOptionPane.showMessageDialog( JOptionUtils.centeringComp(), "Data set must be either continuous or discrete."); } } } }); }
private Container createAuthorPane() { // Create buttons JButton showAuthor = new JButton(new ShowAuthorAction()); JButton showAllAuth = new JButton(new ShowAllAuthorsAction()); JButton deleteAuthor = new JButton(new DeleteAuthorAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(showAuthor); pane.add(Box.createHorizontalStrut(5)); pane.add(showAllAuth); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteAuthor); pane.add(Box.createHorizontalGlue()); return pane; }
public ErrorListDialog( Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) { super(frame, title, true); JPanel content = new JPanel(new BorderLayout(12, 12)); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); Box iconBox = new Box(BoxLayout.Y_AXIS); iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon"))); iconBox.add(Box.createGlue()); content.add(BorderLayout.WEST, iconBox); JPanel centerPanel = new JPanel(new BorderLayout()); JLabel label = new JLabel(caption); label.setBorder(new EmptyBorder(0, 0, 6, 0)); centerPanel.add(BorderLayout.NORTH, label); JList errors = new JList(messages); errors.setCellRenderer(new ErrorListCellRenderer()); errors.setVisibleRowCount(Math.min(messages.size(), 4)); JScrollPane scrollPane = new JScrollPane( errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); Dimension size = scrollPane.getPreferredSize(); size.width = Math.min(size.width, 400); scrollPane.setPreferredSize(size); centerPanel.add(BorderLayout.CENTER, scrollPane); content.add(BorderLayout.CENTER, centerPanel); Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(new ActionHandler()); if (showPluginMgrButton) { pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager")); pluginMgr.addActionListener(new ActionHandler()); buttons.add(pluginMgr); buttons.add(Box.createHorizontalStrut(6)); } buttons.add(ok); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); getRootPane().setDefaultButton(ok); pack(); setLocationRelativeTo(frame); show(); }
private Container createCustomerPane() { // Create buttons JButton showCus = new JButton(new ShowCustomerAction()); JButton showAllCus = new JButton(new ShowAllCustomersAction()); JButton deleteCus = new JButton(new DeleteCustomerAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(showCus); pane.add(Box.createHorizontalStrut(5)); pane.add(showAllCus); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteCus); pane.add(Box.createHorizontalGlue()); return pane; }
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); loadButton = new JButton(loadString); loadButton.setActionCommand(loadString); loadButton.addActionListener(new loadListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name; if (listModel.size() > 0) { name = listModel.getElementAt(list.getSelectedIndex()).toString(); } // Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(loadButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
private void addResourceAndQueryField(JXToolBar toolbar) { if (!(getRequest() instanceof RestTestRequestInterface)) { toolbar.addWithOnlyMinimumHeight(resourcePanel); toolbar.add(Box.createHorizontalStrut(4)); toolbar.addWithOnlyMinimumHeight(queryPanel); } }
private JPanel createButtonPanel() { JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); newButton = new JButton("Add"); editButton = new JButton("Edit"); deleteButton = new JButton("Delete"); newButton.setEnabled(false); editButton.setEnabled(false); deleteButton.setEnabled(false); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(newButton); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(editButton); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(deleteButton); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); return buttonPanel; }
/** Marks, wether this date entry is used as a table cell. */ public void setUsedAsTableCell(boolean isCell) { if (isCell) { removeAll(); setBackground(moneyField.getBackground()); moneyField.setBorder(null); add("East", moneyField); add(Box.createHorizontalStrut(GUI.HorizontalLabelDistance)); add(currencyLabel); } }
private Container createBookPane() { // Create buttons JButton bookLookup = new JButton(new BookLookupAction()); JButton showCat = new JButton(new ShowCatalogueAction()); JButton showLoanedBook = new JButton(new ShowLoanedBooksAction()); JButton deleteBook = new JButton(new DeleteBookAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(bookLookup); pane.add(Box.createHorizontalStrut(5)); pane.add(showCat); pane.add(Box.createHorizontalStrut(5)); pane.add(showLoanedBook); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteBook); pane.add(Box.createHorizontalGlue()); return pane; }
/** * Méthode de création du panelInit * * @return */ private JPanel createPanelInit() { JPanel panRight = new JPanel(); panRight.setLayout(new BoxLayout(panRight, BoxLayout.Y_AXIS)); butListParty = new JButton("Liste des parties"); butListParty.addActionListener(this); JPanel panCreate = new JPanel(); panCreate.setLayout(new BoxLayout(panCreate, BoxLayout.X_AXIS)); textCreate = new JTextField("", 40); textCreate.setMaximumSize(textCreate.getPreferredSize()); butCreateParty = new JButton("Creation de parties "); butCreateParty.addActionListener(this); SpinnerModel model = new SpinnerNumberModel(3, 2, 8, 1); spinNbPlayer = new JSpinner(model); spinNbPlayer.setMaximumSize(spinNbPlayer.getPreferredSize()); panCreate.add(new JLabel("Nouveau nom de partie : ")); panCreate.add(textCreate); panCreate.add(Box.createHorizontalStrut(20)); panCreate.add(new JLabel("Nombres de joueurs : ")); panCreate.add(spinNbPlayer); panCreate.add(butCreateParty); JPanel panJoin = new JPanel(); panJoin.setLayout(new BoxLayout(panJoin, BoxLayout.X_AXIS)); textJoin = new JTextField("", 2); textJoin.setMaximumSize(textJoin.getPreferredSize()); butJoinParty = new JButton("Rejoindre la partie "); butJoinParty.addActionListener(this); panJoin.add(new JLabel("Num Partie : ")); panJoin.add(textJoin); panJoin.add(butJoinParty); panRight.add(butListParty); panRight.add(panCreate); panRight.add(panJoin); panRight.add(Box.createVerticalGlue()); textInfoInit = new JTextArea(20, 100); textInfoInit.setLineWrap(true); JScrollPane scroll = new JScrollPane( textInfoInit, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); JPanel panAll = new JPanel(); panAll.setLayout(new BoxLayout(panAll, BoxLayout.X_AXIS)); panAll.add(scroll); panAll.add(panRight); return panAll; }
private void addErrorMessage(final FixableMessageInfo message, Icon icon) { if (message.myLinkText.length() > 0 || message.myAfterLinkText.length() > 0) { HyperlinkLabel warnLabel = new HyperlinkLabel(); warnLabel.setOpaque(false); warnLabel.setHyperlinkText( message.myBeforeLinkText, message.myLinkText, message.myAfterLinkText); warnLabel.setIcon(icon); if (message.myQuickFix != null) { warnLabel.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { message.myQuickFix.run(); } } }); } myErrorMessages.add(warnLabel); } else { JBLabel warnLabel = new JBLabel(); warnLabel.setOpaque(false); warnLabel.setText( "<html><body>" + message.myBeforeLinkText.replace("\n", "<br>") + "</body></html>"); warnLabel.setIcon(icon); myErrorMessages.add(warnLabel); } if (message.myAdditionalFixes != null && message.myAdditionalFixes.size() > 0) { JPanel fixesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); fixesPanel.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 10, 0)); fixesPanel.setOpaque(false); fixesPanel.add(Box.createHorizontalStrut(icon.getIconWidth())); for (Pair<String, Runnable> pair : message.myAdditionalFixes) { HyperlinkLabel fixLabel = new HyperlinkLabel(); fixLabel.setOpaque(false); fixLabel.setHyperlinkText(pair.getFirst()); final Runnable fix = pair.getSecond(); fixLabel.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { fix.run(); } } }); fixesPanel.add(fixLabel); } myErrorMessages.add(fixesPanel); } }
/** * Create the toolbar. By default this reads the resource file for the definition of the toolbar. */ private Component createToolbar() { toolbar = new JToolBar(); for (String toolKey : getToolBarKeys()) { if (toolKey.equals("-")) { toolbar.add(Box.createHorizontalStrut(5)); } else { toolbar.add(createTool(toolKey)); } } toolbar.add(Box.createHorizontalGlue()); return toolbar; }
/** * Creates a button pane in which the given buttons are neatly aligned with proper spacings. * * @param aButtons the buttons to add to the created button pane, will be added in the given * order. * @return the button pane, never <code>null</code>. */ public static JComponent createButtonPane(final JButton... aButtons) { if ((aButtons == null) || (aButtons.length < 1)) { throw new IllegalArgumentException("Need at least one button!"); } final JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder( BorderFactory.createEmptyBorder( BUTTONS_PADDING_TOP, BUTTONS_PADDING_LEFT, BUTTONS_PADDING_BOTTOM, BUTTONS_PADDING_RIGHT)); buttonPane.add(Box.createHorizontalGlue()); // we want equally sized buttons, so we are recording preferred sizes while // adding the buttons and set them to the maximum afterwards... int width = 1; int height = 1; for (JButton button : aButtons) { width = Math.max(width, button.getPreferredSize().width); height = Math.max(height, button.getPreferredSize().height); buttonPane.add(Box.createHorizontalStrut(BUTTONS_SPACING_DEFAULT)); buttonPane.add(button); } buttonPane.add(Box.createHorizontalStrut(BUTTONS_SPACING_DEFAULT)); final Dimension newDims = new Dimension(width, height); // everything added; let's set all sizes for (final JButton button : aButtons) { button.setPreferredSize(newDims); } return buttonPane; }
/** * Create the pixel location panel * * @param labelFont the font for the labels * @return the location panel */ public JPanel createLocationPanel(Font labelFont) { // create a location panel JPanel locationPanel = new JPanel(); locationPanel.setLayout(new FlowLayout()); Box hBox = Box.createHorizontalBox(); // create the labels rowLabel = new JLabel("Row:"); colLabel = new JLabel("Column:"); // create the text fields colValue = new JTextField(Integer.toString(colIndex + numberBase), 6); colValue.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { displayPixelInformation(colValue.getText(), rowValue.getText()); } }); rowValue = new JTextField(Integer.toString(rowIndex + numberBase), 6); rowValue.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { displayPixelInformation(colValue.getText(), rowValue.getText()); } }); // set up the next and previous buttons setUpNextAndPreviousButtons(); // set up the font for the labels colLabel.setFont(labelFont); rowLabel.setFont(labelFont); colValue.setFont(labelFont); rowValue.setFont(labelFont); // add the items to the vertical box and the box to the panel hBox.add(Box.createHorizontalGlue()); hBox.add(rowLabel); hBox.add(rowPrevButton); hBox.add(rowValue); hBox.add(rowNextButton); hBox.add(Box.createHorizontalStrut(10)); hBox.add(colLabel); hBox.add(colPrevButton); hBox.add(colValue); hBox.add(colNextButton); locationPanel.add(hBox); hBox.add(Box.createHorizontalGlue()); return locationPanel; }