List of usage examples for javax.swing Box createVerticalGlue
public static Component createVerticalGlue()
From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java
private void layoutGuiComponents() { ///*from w w w. ja v a2s . co m*/ // top level panel // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(new EmptyBorder(24, 24, 24, 24)); add(ignoreConflictsCheckbox); add(Box.createVerticalGlue()); }
From source file:CommonLayouts.java
public CommonLayouts() { super("Common Layout Managers"); setSize(500, 380);/*from w w w. j av a 2s . c o m*/ JPanel desktop = new JPanel(); getContentPane().add(desktop); JPanel fr1 = new JPanel(); fr1.setBorder(new TitledBorder("FlowLayout")); fr1.setLayout(new FlowLayout()); fr1.add(new JButton("1")); fr1.add(new JButton("2")); fr1.add(new JButton("3")); fr1.add(new JButton("4")); desktop.add(fr1, 0); JPanel fr2 = new JPanel(); fr2.setBorder(new TitledBorder("GridLayout")); fr2.setLayout(new GridLayout(2, 2)); fr2.add(new JButton("1")); fr2.add(new JButton("2")); fr2.add(new JButton("3")); fr2.add(new JButton("4")); desktop.add(fr2, 0); JPanel fr3 = new JPanel(); fr3.setBorder(new TitledBorder("BorderLayout")); fr3.add(new JButton("1"), BorderLayout.NORTH); fr3.add(new JButton("2"), BorderLayout.EAST); fr3.add(new JButton("3"), BorderLayout.SOUTH); fr3.add(new JButton("4"), BorderLayout.WEST); desktop.add(fr3, 0); JPanel fr4 = new JPanel(); fr4.setBorder(new TitledBorder("BoxLayout - X")); fr4.setLayout(new BoxLayout(fr4, BoxLayout.X_AXIS)); fr4.add(new JButton("1")); fr4.add(Box.createHorizontalStrut(12)); fr4.add(new JButton("2")); fr4.add(Box.createGlue()); fr4.add(new JButton("3")); fr4.add(Box.createHorizontalGlue()); fr4.add(new JButton("4")); desktop.add(fr4, 0); JPanel fr5 = new JPanel(); fr5.setBorder(new TitledBorder("BoxLayout - Y")); fr5.setLayout(new BoxLayout(fr5, BoxLayout.Y_AXIS)); fr5.add(new JButton("1")); fr5.add(Box.createVerticalStrut(10)); fr5.add(new JButton("2")); fr5.add(Box.createGlue()); fr5.add(new JButton("3")); fr5.add(Box.createVerticalGlue()); fr5.add(new JButton("4")); desktop.add(fr5, 0); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.game.ui.views.UserDialog.java
public UserDialog(String message, JFrame frame) { setLayout(new BorderLayout(5, 5)); setModalityType(ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setResizable(false);/* www .j a va 2 s .c om*/ ImageIcon icon = null; try { icon = GameUtils.shrinkImage("warning.gif", 30, 30); } catch (IOException e) { System.out.println("Dialog : showDialogForMap(): Exception occured :" + e); e.printStackTrace(); } JPanel panel = new JPanel(); JLabel label = new JLabel(icon); panel.setLayout(new FlowLayout(FlowLayout.LEFT)); label.setText(message); label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); label.setHorizontalAlignment(0); panel.add(label); add(panel, BorderLayout.NORTH); JPanel contentPanel = new JPanel(); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); txt = new JTextField(); txt.setPreferredSize(new Dimension(150, 30)); txt.setAlignmentX(.5f); txt.setMaximumSize(new Dimension(150, 30)); contentPanel.add(txt); contentPanel.add(Box.createVerticalStrut(10)); JButton btn = new JButton("Submit."); btn.setAlignmentX(.5f); btn.setPreferredSize(new Dimension(50, 25)); btn.addActionListener(this); validationMess = new JLabel("All fields are mandatory"); validationMess.setVisible(false); validationMess.setForeground(Color.red); validationMess.setAlignmentX(.5f); contentPanel.add(btn); contentPanel.add(Box.createVerticalStrut(10)); contentPanel.add(validationMess); contentPanel.add(Box.createVerticalGlue()); add(contentPanel, BorderLayout.CENTER); pack(); setSize(new Dimension(300, 200)); setLocationRelativeTo(frame); setVisible(true); }
From source file:org.ut.biolab.medsavant.client.view.genetics.inspector.CollapsibleInspector.java
public void setMessage(String msg, String helpTitle, String helpMessage) { JPanel messagePanel = ViewUtil.getClearPanel();//new JPanel(); messagePanel.setBorder(ViewUtil.getHugeBorder()); ViewUtil.applyVerticalBoxLayout(messagePanel); JLabel h2 = new JLabel(msg); messagePanel.add(Box.createVerticalGlue()); messagePanel.add(ViewUtil.centerHorizontally(h2)); messagePanel.add(Box.createVerticalStrut(3)); messagePanel.add(ViewUtil.centerHorizontally(ViewUtil.getHelpButton(helpTitle, helpMessage))); messagePanel.add(Box.createVerticalGlue()); setMessage(messagePanel);/*from ww w .j av a 2s . c o m*/ }
From source file:EditorPaneExample7.java
public EditorPaneExample7() { super("JEditorPane Example 7"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/* w w w. j a v a 2 s. co m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); getContentPane().add(panel, "South"); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); saveButton = new JButton("Save"); plain = new JCheckBox("Plain Text"); html = new JCheckBox("HTML"); rtf = new JCheckBox("RTF"); panel.add(plain); panel.add(html); panel.add(rtf); ButtonGroup group = new ButtonGroup(); group.add(plain); group.add(html); group.add(rtf); plain.setSelected(true); panel.add(Box.createVerticalStrut(10)); panel.add(saveButton); panel.add(Box.createVerticalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); getContentPane().add(panel, "East"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Writer w = null; OutputStream os = System.out; String contentType; if (plain.isSelected()) { contentType = "text/plain"; w = new OutputStreamWriter(os); } else if (html.isSelected()) { contentType = "text/html"; w = new OutputStreamWriter(os); } else { contentType = "text/rtf"; } EditorKit kit = pane.getEditorKitForContentType(contentType); try { if (w != null) { kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength()); w.flush(); } else { kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength()); os.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); }
From source file:org.ut.biolab.medsavant.client.view.LoginView.java
/** Creates new form LoginForm */ public LoginView() { initComponents();//from w w w.j a v a 2s .c o m if (ClientMiscUtils.MAC) { this.progressSigningIn.putClientProperty("JProgressBar.style", "circular"); } this.progressSigningIn.setVisible(false); titlePanel.setBackground(ViewUtil.getBGColor()); loginButton.setOpaque(false); userField.setText(controller.getUserName()); passwordField.setText(controller.getPassword()); SettingsController settings = SettingsController.getInstance(); userField.setText(settings.getUsername()); if (settings.getRememberPassword()) { passwordField.setText(settings.getPassword()); } versionLabel.setText("MedSavant " + MedSavantProgramInformation.getVersion()); titlePanel.add(Box.createVerticalGlue(), 0); spiralPanel.setLayout(new BorderLayout()); spiralPanel.add(new SpiralPanel(), BorderLayout.CENTER); detailsPanel.setVisible(false); databaseField.setText(settings.getDBName()); portField.setText(settings.getServerPort()); hostField.setText(settings.getServerAddress()); setOpaque(false); setMaximumSize(new Dimension(400, 400)); }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
public WebServiceExportDialog(JuxtaAuthorFrame frame, WebServiceClient wsClient) { super(frame); this.juxtaFrame = frame; if (wsClient == null) { this.wsClient = new WebServiceClient(frame.getWebServiceUrl()); } else {/*from w w w . ja v a 2 s.c o m*/ this.wsClient = wsClient; } // size and title the main dialog body setTitle("Juxta Web Export"); setResizable(false); setSize(495, 345); setLocationRelativeTo(getParent()); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); getContentPane().setLayout(new BorderLayout(15, 15)); getContentPane().setBackground(Color.white); // add the logo to the top left JPanel logoPnl = new JPanel(); logoPnl.setBackground(Color.white); logoPnl.setLayout(new BoxLayout(logoPnl, BoxLayout.Y_AXIS)); logoPnl.add(new JLabel(JuxtaUserInterfaceStyle.JUXTA_LOGO)); logoPnl.add(Box.createVerticalGlue()); getContentPane().add(logoPnl, BorderLayout.WEST); createSetupPane(); createStatusPane(); getContentPane().add(this.setupPanel, BorderLayout.CENTER); getContentPane().add(createButtonBar(), BorderLayout.SOUTH); // create a single scheduled executor to periodically // check for export status. There can only be one at any // give time, so a pool seemed unnecessary this.scheduler = Executors.newSingleThreadScheduledExecutor(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); }
From source file:org.ecoinformatics.seek.ecogrid.RegistrySearchDialog.java
private void initMainPanel() { JPanel selectionPanel = new JPanel(); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.X_AXIS)); initOptions();/*from w ww . j a v a 2 s . c om*/ optionList = new JComboBox(options); optionList.setEditable(false); optionList.addItemListener(new TextFieldEnableController()); selectionPanel.add(optionList); selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP)); JLabel label = new JLabel(CONTAINS); selectionPanel.add(label); selectionPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.GAP)); inputField.setEnabled(false); selectionPanel.add(inputField); selectionPanel.add(Box.createHorizontalGlue()); mainPanel.setLayout(new BorderLayout()); mainPanel.add(selectionPanel, BorderLayout.NORTH); mainPanel.add(Box.createVerticalGlue(), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); JPanel rightButtonPanel = new JPanel(); rightButtonPanel.setLayout(new BoxLayout(rightButtonPanel, BoxLayout.X_AXIS)); /*searchButton = new JButton(new SearchRegistryAction("Search", this, parent, parent.getLocation())); searchButton.setPreferredSize(ServicesDisplayFrame.BUTTONDIMENSION); searchButton.setMaximumSize(ServicesDisplayFrame.BUTTONDIMENSION); rightButtonPanel.add(searchButton);*/ rightButtonPanel.add(Box.createHorizontalStrut(EcogridPreferencesTab.MARGINGSIZE)); cancelButton = new JButton(new CancelSearchAction("Cancel", this, parent)); cancelButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION); cancelButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION); rightButtonPanel.add(cancelButton); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(Box.createHorizontalGlue(), BorderLayout.CENTER); buttonPanel.add(rightButtonPanel, BorderLayout.EAST); mainPanel.add(buttonPanel, BorderLayout.SOUTH); }
From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java
private void initComponents() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); addButton.setText("Add Next Chronicle"); addButton.setActionCommand(ADD_COMMAND); allButton.setText("All"); allButton.setActionCommand(ALL_COMMAND); noneButton.setText("None"); noneButton.setActionCommand(NONE_COMMAND); Box hbox = Box.createHorizontalBox(); hbox.add(Box.createRigidArea(new Dimension(5, 0))); hbox.add(new JLabel("Check an item to include on your Character Sheet")); hbox.add(Box.createRigidArea(new Dimension(5, 0))); hbox.add(allButton);//from ww w.j ava2s . c o m hbox.add(Box.createRigidArea(new Dimension(3, 0))); hbox.add(noneButton); hbox.add(Box.createHorizontalGlue()); add(Box.createVerticalStrut(5)); add(hbox); add(Box.createVerticalStrut(10)); JScrollPane pane = new JScrollPane(chroniclesPane) { @Override public Dimension getMaximumSize() { Dimension size = getPreferredSize(); size.width = Integer.MAX_VALUE; return size; } @Override public boolean isValidateRoot() { return false; } }; pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); add(pane); add(Box.createVerticalStrut(10)); addButton.setAlignmentX(0.5f); add(addButton); add(Box.createVerticalStrut(5)); add(Box.createVerticalGlue()); }
From source file:org.stanwood.swing.AboutDialog.java
private JComponent createAboutTab() { JScrollPane scroll = new JScrollPane(); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); box.add(Box.createVerticalGlue()); if (message != null) { JXLabel lblMessage = new JXLabel(message); lblMessage.setLineWrap(true);/*from w w w . j av a 2 s. co m*/ box.add(lblMessage); } if (appUrl != null) { JXHyperlink link = new JXHyperlink(new LinkAction(this, appUrl, appUrl)); box.add(link); } box.add(Box.createVerticalGlue()); scroll.getViewport().add(box); return scroll; }