Example usage for javax.swing Box createVerticalStrut

List of usage examples for javax.swing Box createVerticalStrut

Introduction

In this page you can find the example usage for javax.swing Box createVerticalStrut.

Prototype

public static Component createVerticalStrut(int height) 

Source Link

Document

Creates an invisible, fixed-height component.

Usage

From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java

private void createInterface() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = 2;// w ww .j av  a2s .  com
    constraints.gridx = 0;
    constraints.gridy = -1;
    constraints.weightx = 1.0D;

    add(Box.createGlue());

    JLabel usernameLabel = new JLabel("Pseudo : ");
    Font labelFont = usernameLabel.getFont().deriveFont(1);
    Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F);

    usernameLabel.setFont(labelFont);
    add(usernameLabel, constraints);
    add(this.usernameField, constraints);

    add(Box.createVerticalStrut(10), constraints);

    JLabel passwordLabel = new JLabel("Mot de passe :");
    passwordLabel.setFont(labelFont);
    add(passwordLabel, constraints);
    add(this.passwordField, constraints);

    JLabel forgotPasswordLabel = new JLabel("(oubli ?)");
    forgotPasswordLabel.setCursor(new Cursor(12));
    forgotPasswordLabel.setFont(smalltextFont);
    forgotPasswordLabel.setHorizontalAlignment(4);
    forgotPasswordLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            try {
                Util.openLink(Variables.lost);
            } catch (Exception e1) {
                LogInForm.this.login.getLauncher().getLogger()
                        .error("Impossible d'ouvrir le lien pour les logins oublis");
                JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(),
                        "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants",
                        "Impossible d'ouvrir l'URL", 0);
            }
        }
    });
    add(forgotPasswordLabel, constraints);

    createUserDropdownPanel(labelFont);
    add(this.userDropdownPanel, constraints);

    add(Box.createVerticalStrut(10), constraints);
}

From source file:com.game.ui.views.CharachterEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new "
            + "Enemy entity below. Once selected an Enemy character, its' details will be available below");
    noteLbl.setAlignmentX(0);/*from  ww w  .j  ava2 s.c  o m*/
    //        noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (GameCharacter character : GameBean.enemyDetails) {
        System.out.println(character.getName());
        model.addElement(character.getName());
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel enemyDtlLbl = new JLabel("Enemy Character Details : ");
    enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(enemyDtlLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel imageLbl = new JLabel("Image Path : ");
    panel1.add(imageLbl, c);
    c.gridx = 1;
    JTextField image = new JTextField("");
    image.setColumns(20);
    panel1.add(image, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel healthLbl = new JLabel("Health Pts : ");
    panel1.add(healthLbl, c);
    c.gridx = 1;
    JTextField health = new JTextField("");
    health.setColumns(20);
    panel1.add(health, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    JLabel armoursPtsLbl = new JLabel("Armour Points : ");
    panel1.add(armoursPtsLbl, c);
    c.gridx = 1;
    JTextField armourPts = new JTextField("");
    armourPts.setColumns(20);
    panel1.add(armourPts, c);
    c.gridx = 0;
    c.gridy = 6;
    JLabel attackRngeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRngeLbl, c);
    c.gridx = 1;
    JTextField attackRnge = new JTextField("");
    attackRnge.setColumns(20);
    panel1.add(attackRnge, c);
    c.gridx = 0;
    c.gridy = 7;
    JLabel movementLbl = new JLabel("Movement : ");
    panel1.add(movementLbl, c);
    c.gridx = 1;
    JTextField movement = new JTextField("");
    movement.setColumns(20);
    panel1.add(movement, c);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    add(panel1);
    c.gridx = 0;
    c.gridy = 9;
    JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    add(validationMess, c);
    add(Box.createVerticalGlue());
}

From source file:songscribe.ui.UpdateDialog.java

public UpdateDialog(MainFrame mainFrame) {
    super(mainFrame, "Update", true);
    southPanel.remove(applyButton);/*ww  w  .jav  a  2s  .c  o  m*/
    okButton.setText("Update");
    dialogPanel.add(BorderLayout.SOUTH, southPanel);
    JPanel center = new JPanel();
    center.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 10));
    center.setLayout(new BoxLayout(center, BoxLayout.Y_AXIS));
    JLabel label = new JLabel("How do you want to update " + MainFrame.PACKAGE_NAME + "?");
    label.setAlignmentX(0f);
    center.add(label);
    center.add(Box.createVerticalStrut(10));
    updateMode.setAlignmentX(0f);
    center.add(updateMode);
    dialogPanel.add(BorderLayout.CENTER, center);
}

From source file:MultiLineLabel.java

public void addText(String text, int size) {
    if (spacing > 0)
        add(Box.createVerticalStrut(spacing));

    String strs[] = splitLines(text);
    JLabel l;/*from  w  w  w  . j  a  v a  2s.  c o m*/
    Font font = new Font("SansSerif", fontAttributes, size);

    for (int i = 0; strs != null && i < strs.length; i++) {
        l = new JLabel(strs[i]);
        l.setFont(font);
        l.setAlignmentX(alignment);

        if (col != null)
            l.setForeground(col);

        add(l);
    }
}

From source file:com.game.ui.views.WeaponEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new "
                    + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);/*from w  w  w .  ja  v a 2  s .co  m*/
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Item item : GameBean.weaponDetails) {
        if (item instanceof Weapon) {
            model.addElement(((Weapon) item).getName());
        }
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel weaponDtsLbl = new JLabel("Weapon Details : ");
    weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(weaponDtsLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel weaponTypeLbl = new JLabel("Weapon Type : ");
    panel1.add(weaponTypeLbl, c);
    c.gridx = 1;
    JComboBox weaponType = new JComboBox(Configuration.weaponTypes);
    weaponType.setSelectedIndex(0);
    weaponType.setPreferredSize(name.getPreferredSize());
    System.out.println(name.getPreferredSize());
    panel1.add(weaponType, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel attackRangeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRangeLbl, c);
    c.gridx = 1;
    JTextField attackRange = new JTextField("");
    attackRange.setColumns(20);
    panel1.add(attackRange, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    //        c.fill = GridBagConstraints.BOTH;
    //        c.gridy = 7;
    //        c.weightx = 1;
    //        c.weighty = 1;
    //        panel1.add(new JLabel(""), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}

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   w w w .j  a v a  2 s . c o m*/
}

From source file:org.ngrinder.recorder.ui.AboutDialog.java

/**
 * Initialize UI./* w  w  w.  j a  v  a2 s .  c  om*/
 */
protected void initUI() {
    JPanel jContentPane = new JPanel();
    jContentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
    jContentPane.setLayout(new BoxLayout(jContentPane, BoxLayout.Y_AXIS));

    jContentPane.add(getIcon());
    jContentPane.add(Box.createVerticalStrut(16));
    jContentPane.add(getAppName());
    jContentPane.add(Box.createVerticalStrut(8));
    jContentPane.add(getVersion());
    jContentPane.add(Box.createVerticalStrut(8));
    jContentPane.add(getCompany());
    jContentPane.add(getRights());
    jContentPane.add(Box.createVerticalStrut(8));
    jContentPane.add(getLicenseTextArea());
    setContentPane(jContentPane);
}

From source file:org.ut.biolab.medsavant.client.view.genetics.inspector.stat.StaticGeneInspector.java

private StaticGeneInspector() {

    JPanel messagePanel = new JPanel();
    //messagePanel.setBackground(Color.white);
    messagePanel.setBorder(ViewUtil.getHugeBorder());
    ViewUtil.applyVerticalBoxLayout(messagePanel);

    JLabel h1 = new JLabel("No Gene Selected");
    h1.setFont(ViewUtil.getMediumTitleFont());

    String m = "<html><div style=\"text-align: center;\">Choose one from the dropdown box in the Variant Inspector and then click the Inspect button</div></html>";
    JLabel h2 = new JLabel(m);
    h2.setPreferredSize(new Dimension(190, 300));
    h2.setMinimumSize(new Dimension(190, 300));
    h2.setBackground(Color.red);//from   w  w w .jav  a  2 s  . c  o m

    messagePanel.add(ViewUtil.centerHorizontally(h1));
    messagePanel.add(Box.createVerticalStrut(10));
    messagePanel.add(ViewUtil.centerHorizontally(h2));

    this.setMessage(messagePanel);

    addSubInspector(new BasicGeneSubInspector());
    addSubInspector(new OntologySubInspector());
    addSubInspector(new GeneManiaSubInspector());

}

From source file:org.porphyry.view.Opener.java

protected void displayStrut(int height, String side) {
    this.display(Box.createVerticalStrut(height), side);
}

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;//ww  w. j  ava 2  s  .c om
    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");
            }
        }
    });
}