Java JComboBox comboBoxScroll(JComboBox box)

Here you can find the source of comboBoxScroll(JComboBox box)

Description

combo Box Scroll

License

Open Source License

Declaration

public static void comboBoxScroll(JComboBox box) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JComboBox;

import javax.swing.JPopupMenu;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;

public class Main {
    public static void comboBoxScroll(JComboBox box) {
        if (box == null) {
            return;
        }/*from w w w . j a v  a 2 s  .  co  m*/
        Object comp = box.getUI().getAccessibleChild(box, 0);
        if (!(comp instanceof JPopupMenu)) {
            return;
        }
        JPopupMenu popup = (JPopupMenu) comp;
        final JScrollPane scrollPane = (JScrollPane) popup.getComponent(0);
        scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }
}

Related

  1. adjustPopupWidth(JComboBox comboBox)
  2. adjustSize(JComboBox comboBox)
  3. applyDefaultProperties(final JComboBox comp)
  4. CargarComboBox(JComboBox cb, List lista)
  5. checkJComboBoxNotEmpty(javax.swing.JComboBox combo, javax.swing.JLabel promptName, ArrayList errors)
  6. comboContainsElement(JComboBox combo, String element)
  7. contains(JComboBox jcb, Object o, boolean caseSensitive)
  8. createLabelCombo(String label, JComboBox comboBox)
  9. disableListenersForComboBox(JComboBox comboBox)