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

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

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

JComboBox.getMaximumRowCount介绍

暂无

代码示例

代码示例来源:origin: khuxtable/seaglass

/**
 * Get the maximum row count to display. If none is set, return 100.
 *
 * @return the maximum row count to display.
 */
private int getMaximumRowCount() {
  // return isEditable() ? comboBox.getMaximumRowCount() : 100;
  return comboBox.getMaximumRowCount();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project

public int getMaximumRowCount() {
  return combo.getMaximumRowCount();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

int getNextIndex(JComboBox comboBox)
  {
    switch (keyCode)
    {
      case KeyEvent.VK_PAGE_UP :
        int listHeight= comboBox.getMaximumRowCount();
        int index= comboBox.getSelectedIndex() - listHeight;
        return (index < 0 ? 0 : index);
      case KeyEvent.VK_PAGE_DOWN :
        listHeight= comboBox.getMaximumRowCount();
        index= comboBox.getSelectedIndex() + listHeight;
        int max= comboBox.getItemCount();
        return (index < max ? index : max - 1);
      case KeyEvent.VK_HOME :
        return 0;
      case KeyEvent.VK_END :
        return comboBox.getItemCount() - 1;
      default :
        return comboBox.getSelectedIndex();
    }
  }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

break;
case KeyEvent.VK_PAGE_UP:
  next = sel - comboBox.getMaximumRowCount();
  break;
case KeyEvent.VK_PAGE_DOWN:
  next = sel + comboBox.getMaximumRowCount();
  break;
case KeyEvent.VK_HOME:

代码示例来源:origin: BaseXdb/basex

/**
  * Constructor.
  * @param combo combobox reference
  */
 GUIInputPopup(final JComboBox<Object> combo) {
  super(combo);
  final int h = combo.getMaximumRowCount();
  setPreferredSize(new Dimension(getPreferredSize().width, getPopupHeightForRowCount(h) + 2));
 }
}

代码示例来源:origin: org.basex/basex

/**
  * Constructor.
  * @param combo combobox reference
  */
 GUIInputPopup(final JComboBox<Object> combo) {
  super(combo);
  final int h = combo.getMaximumRowCount();
  setPreferredSize(new Dimension(getPreferredSize().width, getPopupHeightForRowCount(h) + 2));
 }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

break;
case KeyEvent.VK_PAGE_UP:
  next = sel - comboBox.getMaximumRowCount();
  break;
case KeyEvent.VK_PAGE_DOWN:
  next = sel + comboBox.getMaximumRowCount();
  break;
case KeyEvent.VK_HOME:

代码示例来源:origin: com.github.insubstantial/substance

int npw = c.getPreferredSize().width;
boolean hasVerticalScrollBar = this.comboBox.getItemCount() > this.comboBox
    .getMaximumRowCount();
if (hasVerticalScrollBar) {

代码示例来源:origin: org.java.net.substance/substance

int npw = c.getPreferredSize().width;
boolean hasVerticalScrollBar = this.comboBox.getItemCount() > this.comboBox
    .getMaximumRowCount();
if (hasVerticalScrollBar) {

代码示例来源:origin: jawi/ols

Math.min( aComboBox.getMaximumRowCount(), aAddedItemCount ) );

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

final Rectangle rect = list.getVisibleRect();
final int first = list.locationToIndex(rect.getLocation());
final int last = first + fontsBox.getMaximumRowCount() - 1;
String selectedItem = fontsBox.getSelectedItem().toString();
System.out.println("1stIndex = " + first + ", LastIndex = "

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Calculates the upper left location of the popup.
 * 
 * @return The upper left location of the popup.
 */
private Point getPopupLocation() {
  Dimension popupSize = this.comboBox.getSize();
  Insets insets = this.getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), this
      .getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
  Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
      .getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  this.scroller.setMaximumSize(scrollSize);
  this.scroller.setPreferredSize(scrollSize);
  this.scroller.setMinimumSize(scrollSize);
  this.list.revalidate();
  return new Point(popupLocation.x, popupLocation.y);
}

代码示例来源:origin: com.synaptix/SynaptixTattoo

/**
 * Calculates the upper left location of the Popup.
 */
private Point getPopupLocation() {
  int h = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
  Dimension pl = list.getPreferredSize();
  Dimension popupSize = comboBox.getSize();
  // TODO Modif de Gaby pour agrandir la combo box
  popupSize.width = Math
      .max(
          popupSize.width,
          (pl.getHeight() > h ? pl.width
              + scroller.getVerticalScrollBar()
                  .getPreferredSize().width : pl.width) + 2);
  Insets insets = getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), h);
  Rectangle popupBounds = computePopupBounds(0,
      comboBox.getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  scroller.setMaximumSize(scrollSize);
  scroller.setPreferredSize(scrollSize);
  scroller.setMinimumSize(scrollSize);
  list.revalidate();
  return popupLocation;
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Calculates the upper left location of the popup.
 * 
 * @return The upper left location of the popup.
 */
private Point getPopupLocation() {
  Dimension popupSize = this.comboBox.getSize();
  Insets insets = this.getInsets();
  // reduce the width of the scrollpane by the insets so that the popup
  // is the same width as the combo box.
  popupSize.setSize(popupSize.width - (insets.right + insets.left), this
      .getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
  Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
      .getBounds().height, popupSize.width, popupSize.height);
  Dimension scrollSize = popupBounds.getSize();
  Point popupLocation = popupBounds.getLocation();
  this.scroller.setMaximumSize(scrollSize);
  this.scroller.setPreferredSize(scrollSize);
  this.scroller.setMinimumSize(scrollSize);
  this.list.revalidate();
  return new Point(popupLocation.x, popupLocation.y);
}

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

preferred.width += 20; // allow for scrollbar
int rowHeight = preferred.height / comboBox.getItemCount();
int maxHeight = comboBox.getMaximumRowCount() * rowHeight;
preferred.height = Math.min(preferred.height, maxHeight);

代码示例来源:origin: omegat-org/omegat

if (sourceLocaleField.getMaximumRowCount() < 20) {
  sourceLocaleField.setMaximumRowCount(20);
if (targetLocaleField.getMaximumRowCount() < 20) {
  targetLocaleField.setMaximumRowCount(20);
if (sourceTokenizerField.getMaximumRowCount() < 20) {
  sourceTokenizerField.setMaximumRowCount(20);
if (targetTokenizerField.getMaximumRowCount() < 20) {
  targetTokenizerField.setMaximumRowCount(20);

代码示例来源:origin: FellowTraveler/otapij

@Override
 public void show() {
  Dimension popupSize = ((SteppedComboBox) comboBox)
    .getPopupSize();
  popupSize
    .setSize(popupSize.width,
      getPopupHeightForRowCount(comboBox
        .getMaximumRowCount()));
  Rectangle popupBounds = computePopupBounds(0, comboBox
    .getBounds().height, popupSize.width, popupSize.height);
  scroller.setMaximumSize(popupBounds.getSize());
  scroller.setPreferredSize(popupBounds.getSize());
  scroller.setMinimumSize(popupBounds.getSize());
  list.invalidate();
  int selectedIndex = comboBox.getSelectedIndex();
  if (selectedIndex == -1) {
   list.clearSelection();
  } else {
   list.setSelectedIndex(selectedIndex);
  }
  list.ensureIndexIsVisible(list.getSelectedIndex());
  setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
  show(comboBox, popupBounds.x, popupBounds.y);
 }
};

代码示例来源:origin: org.ihtsdo/wb-api

public void show() {
    int widestWidth = getWidestItemWidth();
    if (widestWidth < comboBox.getPreferredSize().width) {
      widestWidth = comboBox.getPreferredSize().width;
    }
    Dimension popupSize = comboBox.getSize();
    popupSize.setSize(widestWidth + (2 * padding),
      getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
    Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width,
      popupSize.height);
    scroller.setMaximumSize(popupBounds.getSize());
    scroller.setPreferredSize(popupBounds.getSize());
    scroller.setMinimumSize(popupBounds.getSize());
    list.invalidate();
    int selectedIndex = comboBox.getSelectedIndex();
    if (selectedIndex == -1) {
      list.clearSelection();
    } else {
      list.setSelectedIndex(selectedIndex);
    }
    list.ensureIndexIsVisible(list.getSelectedIndex());
    setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
    show(comboBox, popupBounds.x, popupBounds.y);
  }
};

相关文章

JComboBox类方法