javax.swing.JComboBox.getPreferredSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(168)

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

JComboBox.getPreferredSize介绍

暂无

代码示例

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

protected JComboBox createLogLevelCombo() {
 JComboBox result = new JComboBox();
 Iterator levels = getLogLevels();
 while (levels.hasNext()) {
  result.addItem(levels.next());
 }
 result.setSelectedItem(_leastSevereDisplayedLogLevel);
 result.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
   JComboBox box = (JComboBox) e.getSource();
   LogLevel level = (LogLevel) box.getSelectedItem();
   setLeastSevereDisplayedLogLevel(level);
  }
 });
 result.setMaximumSize(result.getPreferredSize());
 return result;
}

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

newButton.setAlignmentX(0.5f);
fontCombo.setMaximumSize(fontCombo.getPreferredSize());
fontSizeCombo.setMaximumSize(
  fontSizeCombo.getPreferredSize());

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

windowList.setAlignmentX(CENTER_ALIGNMENT);
windowList.setSelectedIndex(selected);
windowList.setMaximumSize(windowList.getPreferredSize());
windowList.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

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

windowList.setAlignmentX(CENTER_ALIGNMENT);
windowList.setSelectedIndex(selected);
windowList.setMaximumSize(windowList.getPreferredSize());
windowList.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

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

windowList.setAlignmentX(CENTER_ALIGNMENT);
windowList.setSelectedIndex(selected);
windowList.setMaximumSize(windowList.getPreferredSize());
windowList.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

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

windowList.setAlignmentX(CENTER_ALIGNMENT);
windowList.setSelectedIndex(selected);
windowList.setMaximumSize(windowList.getPreferredSize());
windowList.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

代码示例来源:origin: chewiebug/GCViewer

private GCViewerGuiToolBar initToolBar(Map<String, Action> actions) {
  GCViewerGuiToolBar toolBar = new GCViewerGuiToolBar();
  toolBar.setFloatable(false);
  
  toolBar.add(actions.get(ActionCommands.OPEN_FILE.toString()));
  toolBar.add(actions.get(ActionCommands.OPEN_SERIES.toString()));
  toolBar.add(actions.get(ActionCommands.OPEN_URL.toString()));
  toolBar.add(actions.get(ActionCommands.EXPORT.toString()));
  toolBar.add(actions.get(ActionCommands.REFRESH.toString()));
  
  JToggleButton watchToggle = new JToggleButton();
  watchToggle.setAction(actions.get(ActionCommands.WATCH.toString()));
  watchToggle.setText("");
  toolBar.addWatchToggleButton(watchToggle);
  
  toolBar.addSeparator();
  
  JComboBox<String> zoomComboBox = new JComboBox<String>(new String[] {"1%", "5%", "10%", "50%", "100%", "200%", "300%", "500%", "1000%", "5000%"});
  zoomComboBox.setSelectedIndex(2);
  zoomComboBox.setAction(actions.get(ActionCommands.ZOOM.toString()));
  zoomComboBox.setEditable(true);
  zoomComboBox.setMaximumSize(zoomComboBox.getPreferredSize());
  toolBar.addZoomComboBox(zoomComboBox);
  
  toolBar.addSeparator();
  
  toolBar.add(actions.get(ActionCommands.ABOUT.toString()));
  
  return toolBar;
}

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

box.setPreferredSize(new Dimension(box.getPreferredSize().width, 25));
box.setRenderer(new ComboBoxListRenderer());
box.setForeground(Color.WHITE);

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

public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JComboBox box = (JComboBox) e.getSource();
  Object comp = box.getUI().getAccessibleChild(box, 0);
  if (!(comp instanceof JPopupMenu)) return;
  JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
  Dimension size = new Dimension();
  size.width = box.getPreferredSize().width;
  size.height = scrollPane.getPreferredSize().height;
  scrollPane.setPreferredSize(size);
  //  following line for Tiger
  // scrollPane.setMaximumSize(size);
}

代码示例来源:origin: pentaho/mondrian

listEditor.setPreferredSize(
  new java.awt.Dimension(
    listEditor.getPreferredSize().width,
    24)); // Do not remove this

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

protected JComboBox<String> combo( int initial , String... items ) {
  JComboBox<String> c = new JComboBox<>();
  for (int i = 0; i < items.length; i++) {
    c.addItem(items[i]);
  }
  c.setSelectedIndex(initial);
  c.addActionListener((ActionListener)this);
  c.setMaximumSize(c.getPreferredSize());
  return c;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

@Override
 protected Rectangle computePopupBounds( int px, int py, int pw, int ph )
 {
  return super.computePopupBounds(
   px, py, Math.max( comboBox.getPreferredSize().width, pw ), ph
  );
 }
};

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/**
   * Adds the given text to the history.
   */
  public void addToHistory(String text) {
    comboBox.addItem(text);
    comboBox.setPreferredSize
      (new Dimension(0, comboBox.getPreferredSize().height));
  }
}

代码示例来源:origin: org.boofcv/visualize

public SelectAlgorithmPanel() {
  super(new BorderLayout());
  toolbar = new JToolBar();
  algBox = new JComboBox();
  algBox.setMaximumSize(algBox.getPreferredSize());
  toolbar.add(algBox);
  algBox.addActionListener(this);
  toolbar.add(Box.createHorizontalGlue());
  add(toolbar, BorderLayout.PAGE_START);
}

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

public Container createFontBox() {
  final JComboBox fontsBox = new JComboBoxWithBorder();
  fontsBox.setRenderer(new ComboBoxRendererWithTooltip(fontsBox));
  final Dimension preferredSize = fontsBox.getPreferredSize();
  fontsBox.setModel(fonts);
  return fontsBox;
}

代码示例来源:origin: org.boofcv/demonstrations

public VisualizeScorePanel( Listener listener ) {
  setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
  setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  scoreTypes.addActionListener(this);
  scoreTypes.setMaximumSize(scoreTypes.getPreferredSize());
  this.listener = listener;
  addLabeled(scoreTypes, "Score: ", this);
}

代码示例来源:origin: protegeproject/protege

public JComboBox<OWLDatatype> getDatatypeSelector() {
    final OWLModelManager mngr = getOWLModelManager();
    List<OWLDatatype> datatypeList = new ArrayList<>(new OWLDataTypeUtils(mngr.getOWLOntologyManager()).getKnownDatatypes(mngr.getActiveOntologies()));

    Collections.sort(datatypeList, mngr.getOWLObjectComparator());
    datatypeList.add(0, null);

    JComboBox<OWLDatatype> c = new JComboBox<>(new DefaultComboBoxModel<>(datatypeList.toArray(new OWLDatatype [datatypeList.size()])));
    c.setPreferredSize(new Dimension(120, c.getPreferredSize().height));
    c.setRenderer(new OWLCellRendererSimple(owlEditorKit));
    return c;
  }
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

public JComboBox getDatatypeSelector() {
    final OWLModelManager mngr = getOWLModelManager();
    List<OWLDatatype> datatypeList = new ArrayList<OWLDatatype>(new OWLDataTypeUtils(mngr.getOWLOntologyManager()).getKnownDatatypes(mngr.getActiveOntologies()));

    Collections.sort(datatypeList, mngr.getOWLObjectComparator());
    datatypeList.add(0, null);

    JComboBox c = new JComboBox(new DefaultComboBoxModel(datatypeList.toArray()));
    c.setPreferredSize(new Dimension(120, c.getPreferredSize().height));
    c.setRenderer(new OWLCellRendererSimple(owlEditorKit));
    return c;
  }
}

代码示例来源:origin: org.boofcv/demonstrations

public PanelConfigWatershed() {
  selectConnect = new JComboBox(new String[]{"4-Connect","8-Connect"});
  selectConnect.addActionListener(this);
  selectConnect.setMaximumSize(selectConnect.getPreferredSize());
  spinnerSize = new JSpinner(new SpinnerNumberModel(10,0,500,5));
  spinnerSize.addChangeListener(this);
  spinnerSize.setMaximumSize(spinnerSize.getPreferredSize());
  configure();
  addAlignCenter(selectConnect, this);
  addLabeled(spinnerSize, "Min Size", this);
}

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

public Container createSizeBox() {
  final JComboBox sizeBox = new JComboBoxWithBorder(size);
  sizeBox.setPrototypeDisplayValue("88888");
  sizeBox.setPreferredSize(sizeBox.getPreferredSize());
  sizeBox.setEditor(new FixedBasicComboBoxEditor());
  sizeBox.setEditable(true);
  return sizeBox;
}

相关文章

JComboBox类方法