javax.swing.Box.createVerticalStrut()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(340)

本文整理了Java中javax.swing.Box.createVerticalStrut()方法的一些代码示例,展示了Box.createVerticalStrut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Box.createVerticalStrut()方法的具体详情如下:
包路径:javax.swing.Box
类名称:Box
方法名:createVerticalStrut

Box.createVerticalStrut介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/**
 * @return Panel with banner.
 */
private JPanel createBannerPanel() {
  JPanel bannerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5));
  bannerPanel.setBackground(Color.WHITE);
  try {
    URL url = new URL(bannerSpec);
    BufferedImage image = ImageIO.read(url);
    bannerPanel.add(new JLabel(new ImageIcon(image)));
  }
  catch (IOException ioe) {
    ioe.printStackTrace();
  }
  JPanel msgPanel = new JPanel();
  msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.Y_AXIS));
  msgPanel.setBackground(Color.WHITE);
  msgPanel.add(new JLabel("<html><b>About Ignite</b></html>"));
  msgPanel.add(Box.createVerticalStrut(5));
  msgPanel.add(new JLabel(appName));
  bannerPanel.add(msgPanel);
  return bannerPanel;
}

代码示例来源:origin: wildfly/wildfly

Box main_box=Box.createVerticalBox();
main_box.setBackground(Color.white);
Box input=Box.createHorizontalBox();   // input field
Box buttons=Box.createHorizontalBox(); // for all the buttons
mainFrame.add(main_box);
main_box.add(Box.createVerticalStrut(10));
main_box.add(cluster);
cluster.setAlignmentX(Component.LEFT_ALIGNMENT);
main_box.add(Box.createVerticalStrut(10));
main_box.add(Box.createVerticalStrut(10));
main_box.add(users_label);
main_box.add(Box.createVerticalStrut(10));
main_box.add(txtArea);
main_box.add(Box.createVerticalStrut(10));
main_box.add(input);
main_box.add(Box.createVerticalStrut(10));
main_box.add(buttons);

代码示例来源:origin: stackoverflow.com

private JButton addNewFieldBtn = new JButton("Add New Field");
private JButton submitBtn = new JButton("Submit");
private JPanel centerPanel = new JPanel(new GridBagLayout());
private int gridY = 0;
 centerPanel.add(new JLabel("Name:"), gbc);
 gbc = createGBC(1, gridY);
 centerPanel.add(nameField, gbc);     
 centerPanel.add(new JLabel("Search Terms:"), gbc);
 gbc = createGBC(1, gridY);
 centerPanel.add(searchTermsCombo, gbc); 
 JPanel bottomPanel = new JPanel();
 bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.PAGE_AXIS));
 JPanel addNewFieldPanel = new JPanel(new GridLayout(1, 0));
 addNewFieldPanel.add(addNewFieldBtn);
 addNewFieldPanel.add(new JLabel());
 JPanel submitPanel = new JPanel(new BorderLayout());
 submitPanel.add(submitBtn);
 bottomPanel.add(addNewFieldPanel);
 bottomPanel.add(Box.createVerticalStrut(5));
 bottomPanel.add(submitPanel);

代码示例来源:origin: wildfly/wildfly-core

private JPanel makeInputPanel() {
  JPanel inputPanel = new JPanel(new GridBagLayout());
  GridBagConstraints gbc = new GridBagConstraints();
  gbc.gridwidth = GridBagConstraints.REMAINDER;
  gbc.anchor = GridBagConstraints.WEST;
  gbc.fill = GridBagConstraints.HORIZONTAL;
  if (!deploymentChooser.hasDeployments()) {
    inputPanel.add(new JLabel("NO DEPLOYMENTS AVAILABLE TO UNDEPLOY"), gbc);
    return inputPanel;
  }
  inputPanel.add(deploymentChooser, gbc);
  inputPanel.add(keepContent, gbc);
  if (!cliGuiCtx.isStandalone()) {
    inputPanel.add(Box.createVerticalStrut(30), gbc);
    inputPanel.add(serverGroupChooser, gbc);
    inputPanel.add(allRelevantServerGroups, gbc);
  }
  return inputPanel;
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

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);
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_http

/**
 * Initialize the components and layout of this component.
 */
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
  JPanel p = this;
  p.setLayout(new BorderLayout());
  p.add(makeMainPanel(), BorderLayout.CENTER);
  // Force a minimum table height of 70 pixels
  p.add(Box.createVerticalStrut(70), BorderLayout.WEST);
  p.add(makeButtonPanel(), BorderLayout.SOUTH);
  table.revalidate();
}

代码示例来源:origin: robo-code/robocode

public void updateFields() {
    removeAll();
    setSelectedRobots(robotPackager.getRobotSelectionPanel().getSelectedRobots());
    add(getRobotListPanel());
    add(Box.createVerticalStrut(20));
    if (robotPackager.getPackagerOptionsPanel().getIncludeSource().isSelected()) {
      add(new JLabel("Java source files will be included."));
    } else {
      add(new JLabel("Java source files will NOT be included."));
    }
    if (robotPackager.getPackagerOptionsPanel().getIncludeData().isSelected()) {
      add(new JLabel("Data files will be included, if they exists."));
    } else {
      add(new JLabel("Data source files will NOT be included."));
    }
    add(Box.createVerticalStrut(20));
    add(new JLabel("The package will be saved in: " + robotPackager.getFilenamePanel().getFilenameField().getText()));
    add(Box.createVerticalStrut(20));
    add(new JLabel("If all of the above is correct, click the Package button to start packaging."));
    add(new JPanel());

    revalidate();
  }
}

代码示例来源:origin: stackoverflow.com

public void initialDemoPanel(){
  setBorder(BorderFactory.createTitledBorder(getBorder(), "DemoPanel", TitledBorder.LEADING, TitledBorder.TOP, new Font("Default",Font.PLAIN,10), Color.gray));
  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  label1 = new JLabel("This is first line");
  label2 = new JLabel("This is second line");
  initialDemoPanel();
  add(label1);
  add(Box.createVerticalStrut(strutValue));
  add(label2);
  setBorder(BorderFactory.createTitledBorder(getBorder(), "ActionPanel", TitledBorder.LEADING, TitledBorder.TOP, new Font("Default",Font.PLAIN,10), Color.gray));
  setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
  JRadioButton glueButton = new JRadioButton("With Glue");
  glueButton.addActionListener(new glueButtonListener());
  JLabel strutLabel = new JLabel("Strut Value");
  add(strutLabel);
  spinner = new JSpinner(new SpinnerNumberModel(0,0,50,1));

代码示例来源:origin: cmu-phil/tetrad

/**
 * Creates the select variable button.
 */
private JComponent createSelectVariableButton() {
  Box box = Box.createVerticalBox();
  JButton selectVariable = new JButton(">");
  selectVariable.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      Node node = (Node) variableList.getSelectedValue();
      if (node != null) {
        insertSymbol(node.getName());
      }
    }
  });
  box.add(Box.createVerticalStrut(50));
  box.add(selectVariable);
  box.add(Box.createVerticalGlue());
  return box;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void doEncodingPrompt(final String encoding, final String oldEncoding) {
 final JPanel encodingPanel = new JPanel();
 encodingPanel.setLayout(new BoxLayout(encodingPanel, BoxLayout.PAGE_AXIS));
 JLabel text = new JLabel("<html>A head finder or tree reader was selected that has the default encoding " + encoding
   + "; this differs from " + oldEncoding + ", which was being used. If the encoding is changed, all newly loaded" +
   "treebanks will be read using the new encoding. Choosing an encoding that is not the true encoding of your tree " +
 JPanel textPanel = new JPanel(new BorderLayout());
 textPanel.setPreferredSize(new Dimension(100,100));
 textPanel.add(text);
 encodingPanel.add(textPanel);
 encodingPanel.add(Box.createVerticalStrut(5));
 final JOptionPane fileFilterDialog = new JOptionPane();
 fileFilterDialog.setMessage(encodingPanel);

代码示例来源:origin: org.wildfly.core/wildfly-cli

private JPanel makeInputPanel() {
  JPanel inputPanel = new JPanel(new GridBagLayout());
  GridBagConstraints gbc = new GridBagConstraints();
  gbc.gridwidth = GridBagConstraints.REMAINDER;
  gbc.anchor = GridBagConstraints.WEST;
  gbc.fill = GridBagConstraints.HORIZONTAL;
  if (!deploymentChooser.hasDeployments()) {
    inputPanel.add(new JLabel("NO DEPLOYMENTS AVAILABLE TO UNDEPLOY"), gbc);
    return inputPanel;
  }
  inputPanel.add(deploymentChooser, gbc);
  inputPanel.add(keepContent, gbc);
  if (!cliGuiCtx.isStandalone()) {
    inputPanel.add(Box.createVerticalStrut(30), gbc);
    inputPanel.add(serverGroupChooser, gbc);
    inputPanel.add(allRelevantServerGroups, gbc);
  }
  return inputPanel;
}

代码示例来源:origin: com.jalalkiswani/jk-desktop

/**
 *
 * @param comp
 * @return
 */
private Component borderComponent(final Component comp) {
  final Box horizBox = Box.createHorizontalBox();
  horizBox.add(Box.createHorizontalGlue());
  horizBox.add(comp);
  horizBox.add(Box.createHorizontalGlue());
  final Box vertBox = Box.createVerticalBox();
  vertBox.add(Box.createVerticalStrut(5));
  vertBox.add(horizBox);
  vertBox.add(Box.createVerticalStrut(5));
  return vertBox;
}

代码示例来源:origin: stackoverflow.com

chatArea.setFocusable(false);
JScrollPane chatScroll = new JScrollPane(chatArea);
JPanel chatPanel = new JPanel(new BorderLayout());
chatPanel.add(new JLabel("Chat:", SwingConstants.LEFT), BorderLayout.PAGE_START);
chatPanel.add(chatScroll);
JPanel inputPanel = new JPanel();
inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.LINE_AXIS));
inputPanel.add(inputField);
inputPanel.add(sendBtn);
JPanel youLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
youLabelPanel.add(new JLabel("You:"));
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
mainPanel.add(chatPanel);
mainPanel.add(Box.createVerticalStrut(10));
mainPanel.add(youLabelPanel);
mainPanel.add(inputPanel);

代码示例来源:origin: viglucci/app-jcef-example

public StatusPanel() {
 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
 add(Box.createHorizontalStrut(5));
 add(Box.createHorizontalStrut(5));
 progressBar_ = new JProgressBar();
 Dimension progressBarSize = progressBar_.getMaximumSize();
 progressBarSize.width = 100;
 progressBar_.setMinimumSize(progressBarSize);
 progressBar_.setMaximumSize(progressBarSize);
 add(progressBar_);
 add(Box.createHorizontalStrut(5));
 status_field_ = new JLabel("Info");
 status_field_.setAlignmentX(LEFT_ALIGNMENT);
 add(status_field_);
 add(Box.createHorizontalStrut(5));
 add(Box.createVerticalStrut(21));
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_java

private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
  setLayout(new BorderLayout(0, 5));
  setBorder(makeBorder());
  Box box = Box.createVerticalBox();
  box.add(makeTitlePanel());
  box.add(createResetPanel());
  box.add(createParameterPanel());
  box.add(createFilenamePanel());
  add(box, BorderLayout.NORTH);
  JPanel panel = createScriptPanel();
  add(panel, BorderLayout.CENTER);
  // Don't let the input field shrink too much
  add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
}

代码示例来源:origin: stanfordnlp/CoreNLP

final JPanel fileFilterPanel = new JPanel();
fileFilterPanel.setLayout(new BoxLayout(fileFilterPanel, BoxLayout.PAGE_AXIS));
JLabel text = new JLabel("<html>Please indicate any constraints on the files you want to load. All files in specified folders that satisfy all of the given constraints will be loaded. Just press Okay to load all files.</html>");
JPanel textPanel = new JPanel(new BorderLayout());
textPanel.setPreferredSize(new Dimension(100,50));
textPanel.add(text);
fileFilterPanel.add(textPanel);
fileFilterPanel.add(Box.createVerticalStrut(5));
Box defaultFilter = getNewFilter();
   JOptionPane.showMessageDialog(dialog, new JLabel("<html>Please check the range you specified for the file number.  Ranges must be numerical, and disjoint <br>ranges should be separated by commas.  For example \"1-200,250-375\" is a valid range.</html>"), "Error in File Number Range", JOptionPane.ERROR_MESSAGE);
   return;

代码示例来源:origin: com.fifesoft.rtext/fife.common

private Container createTopPanel(File source, File dest) {
  Box topPanel = Box.createVerticalBox();
  String temp = getString("Dialog.NameCollision.FileExists",
              source.getAbsolutePath());
  JLabel label = new JLabel(temp);
  JPanel temp2 = new JPanel(new BorderLayout());
  temp2.add(label, BorderLayout.LINE_START);
  topPanel.add(temp2);
  topPanel.add(Box.createVerticalStrut(5));
  String title = getString("Dialog.NameCollision.CurrentFile");
  topPanel.add(new FileInfoPanel(title, dest));
  topPanel.add(Box.createVerticalStrut(5));
  title = getString("Dialog.NameCollision.FileBeingCopied");
  topPanel.add(new FileInfoPanel(title, source));
  topPanel.add(Box.createVerticalGlue());
  return topPanel;
}

代码示例来源:origin: cmu-phil/tetrad

private JComponent createConditionalDisplay() {
  Box conditionalBox = Box.createVerticalBox();
  Box b1 = Box.createHorizontalBox();
  b1.add(new JLabel("Probabilities for values of "));
  b1.add(varNamesComboBox);
  b1.add(new JLabel(" conditional on values"));
  b1.add(Box.createHorizontalGlue());
  conditionalBox.add(b1);
  Box b0 = Box.createHorizontalBox();
  b0.add(new JLabel(
      "of its parents, updated to reflect the following evidence:"));
  b0.add(Box.createHorizontalGlue());
  conditionalBox.add(b0);
  conditionalBox.add(Box.createVerticalStrut(10));
  addListOfEvidence(conditionalBox);
  conditionalBox.add(Box.createVerticalStrut(20));
  Box b2 = Box.createHorizontalBox();
  b2.add(tablePanel);
  conditionalBox.add(b2);
  return conditionalBox;
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
  setLayout(new BorderLayout(0, 5));
  setBorder(makeBorder());
  Box box = Box.createVerticalBox();
  box.add(makeTitlePanel());
  box.add(createResetPanel());
  box.add(createParameterPanel());
  box.add(createFilenamePanel());
  add(box, BorderLayout.NORTH);
  JPanel panel = createScriptPanel();
  add(panel, BorderLayout.CENTER);
  // Don't let the input field shrink too much
  add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
}

代码示例来源:origin: nodebox/nodebox

public PreferencesDialog() {
  super((Frame) null, "Preferences");
  setLocationRelativeTo(null);
  JPanel rootPanel = new JPanel();
  rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS));
  rootPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  JLabel label = new JLabel("<html><i>No preferences yet.</i></html>");
  rootPanel.add(label);
  rootPanel.add(Box.createVerticalStrut(10));
  JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10, 10));
  JButton cancelButton = new JButton("Cancel");
  cancelButton.addActionListener(new ActionListener() {
  buttonPanel.add(cancelButton);
  rootPanel.add(buttonPanel);
  JButton saveButton = new JButton("Save");

相关文章