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

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

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

Box.createHorizontalStrut介绍

暂无

代码示例

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

import javax.swing.*;

public class JOptionPaneMultiInput {
  public static void main(String[] args) {
   JTextField xField = new JTextField(5);
   JTextField yField = new JTextField(5);

   JPanel myPanel = new JPanel();
   myPanel.add(new JLabel("x:"));
   myPanel.add(xField);
   myPanel.add(Box.createHorizontalStrut(15)); // a spacer
   myPanel.add(new JLabel("y:"));
   myPanel.add(yField);

   int result = JOptionPane.showConfirmDialog(null, myPanel, 
        "Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION);
   if (result == JOptionPane.OK_OPTION) {
     System.out.println("x value: " + xField.getText());
     System.out.println("y value: " + yField.getText());
   }
  }
}

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

addButton = new JButton("Add Comp");
  addButton.addActionListener(new ActionListener() {
  JPanel panel = new JPanel(new GridBagLayout());
  panel.add(addButton);
  return panel;
private JLabel labelWith = new JLabel("With ");
private JComboBox typeCombo = new JComboBox(new Object[]{"height", "length", "volume"});
private JComboBox relationCombo = new JComboBox(new Object[]{"above", "below", "between"});
private JTextField lowerField = new JTextField();
private JLabel labelAnd = new JLabel(" and ");
private JTextField upperField = new JTextField();
private JButton removeButton = new JButton("remove");
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  relationCombo.addActionListener(new ActionListener() {
  add(labelAnd);
  add(upperField);
  add(Box.createHorizontalStrut(100));
  add(removeButton);

代码示例来源:origin: dboissier/mongo4idea

@NotNull
private JPanel createRowLimitPanel() {
  rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit()));
  rowLimitField.setColumns(5);
  rowLimitField.setDocument(new NumberDocument());
  rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit()));
  JPanel rowLimitPanel = new NonOpaquePanel();
  rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST);
  rowLimitPanel.add(rowLimitField, BorderLayout.CENTER);
  rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
  return rowLimitPanel;
}

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

public PortNotesRow(String notes) {
  setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  notesLabel = new JLabel(notes);
  notesLabel.setFont(Theme.SMALL_FONT);
  notesLabel.setForeground(Theme.TEXT_NORMAL_COLOR);
  notesLabel.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, BOTTOM_PADDING, 0));
  add(Box.createHorizontalStrut(PortView.LABEL_WIDTH + 10));
  add(this.notesLabel);
  add(Box.createHorizontalGlue());
  setBorder(Theme.PARAMETER_NOTES_BORDER);
}

代码示例来源:origin: Nepxion/Discovery

private void initializeToolBar() {
  JSecurityAction addServiceAction = createAddServiceAction();
  comboBox = new JBasicComboBox();
  comboBox.setPreferredSize(new Dimension(300, comboBox.getPreferredSize().height));
  comboBox.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (comboBox.getSelectedItem() != e.getItem()) {
        addServiceAction.execute(null);
      }
    }
  });
  textField = new JBasicTextField();
  textField.setPreferredSize(new Dimension(650, textField.getPreferredSize().height));
  JToolBar toolBar = getGraph().getToolbar();
  toolBar.addSeparator();
  toolBar.add(Box.createHorizontalStrut(5));
  toolBar.add(new JLabel(ConsoleLocale.getString("service_list")));
  toolBar.add(Box.createHorizontalStrut(5));
  toolBar.add(comboBox);
  toolBar.add(new JClassicButton(addServiceAction));
  toolBar.add(new JClassicButton(createDeleteServiceAction()));
  toolBar.add(textField);
  toolBar.add(new JClassicButton(createExecuteRouterAction()));
  toolBar.add(new JClassicButton(createClearRouterAction()));
  ButtonManager.updateUI(toolBar);
}

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

InfinitestResultsPane() {
  setLayout(new BorderLayout());
  toolbar = createToolBar();
  animator = new ColorAnimator();
  progressBar = createProgressBar();
  tree = createTree();
  JPanel southComponent = new JPanel(new BorderLayout());
  if (UIManager.getSystemLookAndFeelClassName().equals("apple.laf.AquaLookAndFeel")) {
    southComponent.add(Box.createHorizontalStrut(RESIZE_WINDOW_HANDLE_WIDTH), BorderLayout.EAST);
  }
  southComponent.add(progressBar, BorderLayout.CENTER);
  southComponent.add(toolbar, BorderLayout.WEST);
  add(southComponent, BorderLayout.SOUTH);
  add(new JScrollPane(tree), BorderLayout.CENTER);
}

代码示例来源:origin: net.imagej/ij-ui-swing

@Override
public void initialize(final WidgetModel model) {
  super.initialize(model);
  path = new JTextField(16);
  setToolTip(path);
  getComponent().add(path);
  path.getDocument().addDocumentListener(this);
  getComponent().add(Box.createHorizontalStrut(3));
  browse = new JButton("Browse");
  setToolTip(browse);
  getComponent().add(browse);
  browse.addActionListener(this);
  refreshWidget();
}

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

public DeviceRow(JComponent control, ActionListener removeDeviceListener) {
  setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  this.control = control;
  JButton removeDeviceButton = new JButton(minusIcon);
  removeDeviceButton.addActionListener(removeDeviceListener);
  removeDeviceButton.setBorder(null);
  add(this.control);
  add(Box.createHorizontalGlue());
  add(removeDeviceButton);
  add(Box.createHorizontalStrut(26));
  setBorder(new Theme.BottomBorder(new Color(136, 136, 136)));
}

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

private void setRightPanel(JComponent c) {
  this.rightPanel.removeAll();
  if (c != null) {
    this.rightPanel.add(Box.createHorizontalStrut(4));
    this.rightPanel.add(c);
  }
  updateUI();
}

代码示例来源:origin: org.databene/databene-commons

private void completeButtonBar() {
  buttonBar.setBorder(new EmptyBorder(8, 8, 8, 8));
  buttonBar.add(Box.createHorizontalGlue());
  if (cancellable) {
    addButton(cancelAction);
    buttonBar.add(Box.createHorizontalStrut(8));
  }
  JButton okButton = new JButton(okAction);
  buttonBar.add(okButton);
  getRootPane().setDefaultButton(okButton);
  // pack and position the dialog 
  setResizable(false);
  pack();
  setLocationRelativeTo(parentComponent);
  this.completed = true;
}

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

public PortRow(NodeBoxDocument document, String portName, JComponent control) {
  this.document = document;
  this.portName = portName;
  addMouseListener(this);
  setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  Dimension labelSize = new Dimension(PortView.LABEL_WIDTH, 16);
  Port port = getPort();
  label = new ShadowLabel(port.getDisplayLabel());
  if (! port.getDescription().isEmpty())
    label.setToolTipText(port.getName() + ": " + port.getDescription());
  else
    label.setToolTipText(port.getName());
  label.setBorder(null);
  label.setPreferredSize(labelSize);
  label.setMinimumSize(labelSize);
  this.control = control;
  control.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, BOTTOM_PADDING, 0));
  popupMenu = new JPopupMenu();
  popupMenu.add(new RevertToDefaultAction());
  add(this.label);
  add(Box.createHorizontalStrut(10));
  add(this.control);
  add(Box.createHorizontalGlue());
  // Compensate for the popup button.
  add(Box.createHorizontalStrut(30));
  setBorder(Theme.PARAMETER_ROW_BORDER);
}

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

private void initComponents() {
  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");
  finishButton = new JButton("Finish");
  cancelButton = new JButton("Cancel");
  backButton.addActionListener(controller);
  nextButton.addActionListener(controller);
  finishButton.addActionListener(controller);
  cancelButton.addActionListener(controller);
  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(finishButton);
  buttonBox.add(Box.createHorizontalStrut(10));
  buttonBox.add(cancelButton);
  buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST);
  getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
  getContentPane().add(new JScrollPane(cardPanel), java.awt.BorderLayout.CENTER);
}

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

import javax.swing.*;

public class OptionEg {
  public static void main(String[] args) {
   final JTextField ipField = new JTextField(10);
   final JTextField portField = new JTextField(10);
   JPanel panel = new JPanel();
   panel.add(new JLabel("IP:"));
   panel.add(ipField);

   panel.add(Box.createHorizontalStrut(15));
   panel.add(new JLabel("Port:"));
   panel.add(portField);

   int result = JOptionPane.showConfirmDialog(null, panel,
      "Enter Information", JOptionPane.OK_CANCEL_OPTION);

   if (result == JOptionPane.OK_OPTION) {
     System.out.println("IP: " + ipField.getText());
     System.out.println("Port: " + portField.getText());
   }

  }
}

代码示例来源:origin: antlr/antlrworks

public void createTitleBar(String title) {
  Box box = Box.createHorizontalBox();
  JLabel l = new JLabel(title);
  l.setFont(l.getFont().deriveFont(11.0f));
  l.setForeground(Color.white);
  box.add(Box.createHorizontalStrut(2));
  box.add(l);
  box.add(Box.createHorizontalGlue());
  box.add(detach = createDetachButton());
  titlePanel = new TitlePanel();
  titlePanel.setMinimumSize(new Dimension(0, 15));
  titlePanel.setMaximumSize(new Dimension(0, 15));
  titlePanel.setPreferredSize(new Dimension(0, 15));
  titlePanel.add(box);
  super.add(titlePanel, BorderLayout.NORTH);
}

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

public ColorPanel(ColorComponent colorComponent) {
  this.colorComponent = colorComponent;
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  Dimension d = new Dimension(Integer.MAX_VALUE, 30);
  setMinimumSize(d);
  setPreferredSize(d);
  setMaximumSize(d);
  JLabel label = new JLabel(nodebox.util.StringUtils.humanizeName(colorComponent.toString().toLowerCase(Locale.US)), JLabel.RIGHT);
  Dimension size = label.getSize();
  label.setFont(Theme.SMALL_BOLD_FONT);
  label.setForeground(new Color(66, 66, 66));
  label.setPreferredSize(new Dimension(75, size.height));
  label.setAlignmentY(JLabel.CENTER);
  label.setBorder(new EmptyBorder(3, 0, 0, 0));
  add(label);
  add(Box.createHorizontalStrut(2));
  draggableNumber = new DraggableNumber();
  draggableNumber.addChangeListener(this);
  d = new Dimension(20, Integer.MAX_VALUE);
  draggableNumber.setPreferredSize(d);
  draggableNumber.setMaximumSize(d);
  draggableNumber.setSize(d);
  add(draggableNumber);
  slider = new ColorSlider(this);
  add(slider);
  add(Box.createHorizontalStrut(7));
}

代码示例来源:origin: org.databene/jdbacl

private void createToolBar() {
  JToolBar toolBar = new JToolBar();
  add(toolBar, BorderLayout.NORTH);
  toolBar.add(new JLabel("Exclusion:"));
  toolBar.add(exclusionField);
  toolBar.add(Box.createHorizontalStrut(8));
  toolBar.add(new JLabel("Environment:"));
  toolBar.add(environmentSelector);
  toolBar.add(Box.createHorizontalGlue());
  toolBar.setFloatable(false);
}

代码示例来源:origin: org.scijava/scijava-ui-swing

@Override
public void set(final WidgetModel model) {
  super.set(model);
  path = new JTextField(16);
  path.setDragEnabled(true);
  final String style = model.getItem().getWidgetStyle();
  path.setTransferHandler(new FileTransferHandler(style));
  setToolTip(path);
  getComponent().add(path);
  path.getDocument().addDocumentListener(this);
  getComponent().add(Box.createHorizontalStrut(3));
  browse = new JButton("Browse");
  setToolTip(browse);
  getComponent().add(browse);
  browse.addActionListener(this);
  refreshWidget();
}

代码示例来源:origin: SKCraft/SKMCLauncher

public DirectoryField() {
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  
  textField = new JTextField(30);
  textField.setMaximumSize(textField.getPreferredSize());
  add(textField);
  add(Box.createHorizontalStrut(3));
  
  browseButton = new JButton("Browse...");
  browseButton.setPreferredSize(new Dimension(
      browseButton.getPreferredSize().width,
      textField.getPreferredSize().height));
  add(browseButton);
  
  browseButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      browse();
    }
  });
}

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

private void setLeftPanel(JComponent c) {
  this.leftPanel.removeAll();
  if (c != null) {
    this.leftPanel.add(c);
    this.leftPanel.add(Box.createHorizontalStrut(4));
  }
  updateUI();
}

代码示例来源:origin: ganshane/shakey

DetailsRequestPanel() {
  HtmlButton but = new HtmlButton( "Query") {
    @Override protected void actionPerformed() {
      onQuery();
    }
  };
  setLayout( new BoxLayout( this, BoxLayout.X_AXIS) );
  add( m_contractPanel);
  add( Box.createHorizontalStrut(20));
  add( but);
}

相关文章