Example usage for javax.swing JComboBox getMaximumRowCount

List of usage examples for javax.swing JComboBox getMaximumRowCount

Introduction

In this page you can find the example usage for javax.swing JComboBox getMaximumRowCount.

Prototype

public int getMaximumRowCount() 

Source Link

Document

Returns the maximum number of items the combo box can display without a scrollbar

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] items = new String[50];
    for (int i = 0; i < items.length; i++) {
        items[i] = "" + Math.random();
    }/*from w  w w.j  a  va2 s. c  o  m*/
    JComboBox cb = new JComboBox(items);

    // Retrieve the current max visible rows
    int maxVisibleRows = cb.getMaximumRowCount();

    // Change the current max visible rows
    maxVisibleRows = 20;
    cb.setMaximumRowCount(maxVisibleRows);

}

From source file:Main.java

public Main() {
    JComboBox jc = new JComboBox();
    jc.addItem("France");
    jc.addItem("Germany");
    jc.addItem("Italy");
    jc.addItem("Japan");
    jc.addItemListener(this);
    add(jc);//from   ww w . j  a v  a  2s  . c o  m
    System.out.println(jc.getMaximumRowCount());
}

From source file:org.yccheok.jstock.gui.Utils.java

private static int getScrollBarWidth(JComboBox comboBox, JScrollPane scrollPane) {
    int scrollBarWidth = 0;
    if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
        JScrollBar vertical = scrollPane.getVerticalScrollBar();
        scrollBarWidth = vertical.getPreferredSize().width;
    }//from   ww  w .  j  av  a  2 s .  co  m
    return scrollBarWidth;
}