Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ezhov-da/b6eaf756a9fd957410f062772a5769cc to your computer and use it in GitHub Desktop.
Save ezhov-da/b6eaf756a9fd957410f062772a5769cc to your computer and use it in GitHub Desktop.
java добавление горизонтальной прокрутки в jcombobox
[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