private void initComponents() { groupsList = new JList(); add(groupsList); slider = new MultiListSlider(); add(slider); groupsList.setCellRenderer(new MultiListCellRenderer()); updateList(); slider.setMultiListSlidable(this); setPreferredSize( new Dimension( LABEL_SPACE + groupsList.getPreferredSize().width + slider.getWidth(), groupsList.getPreferredSize().height)); setSize(getPreferredSize()); updateLocations(); }
private void updateLocations() { groupsList.setBounds( LABEL_SPACE, 0, groupsList.getPreferredSize().width, groupsList.getPreferredSize().height); slider.setBounds(LABEL_SPACE + groupsList.getWidth(), 0, slider.getWidth(), slider.getHeight()); }
@Override public Dimension getPreferredScrollableViewportSize() { final Dimension dim = groupsList.getPreferredScrollableViewportSize(); return new Dimension( (int) (LABEL_SPACE + dim.getWidth() + slider.getWidth()), (int) dim.getHeight()); }