Last active
March 10, 2019 12:21
-
-
Save ezhov-da/b6eaf756a9fd957410f062772a5769cc to your computer and use it in GitHub Desktop.
java добавление горизонтальной прокрутки в jcombobox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[code:]java[:code] | |
private void adjustScrollBar(JComboBox box) | |
{ | |
if (box.getItemCount() == 0) | |
{ | |
return; | |
} | |
Object comp = box.getUI().getAccessibleChild(box, 0); | |
if (!(comp instanceof JPopupMenu)) | |
{ | |
return; | |
} | |
JPopupMenu popup = (JPopupMenu) comp; | |
JScrollPane scrollPane = (JScrollPane) popup.getComponent(0); | |
scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL)); | |
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); | |
} | |
[/code] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment