private void navigationButtonScreenAdjustments(ScrollTo scrollTo) { scenesDepthFrame.pack(); double width = scenesDepthFrame.getSize().getWidth(); double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); if (width > screenWidth) { Rectangle bounds = scenesDepthFrame.getBounds(); bounds.setRect(bounds.getX(), bounds.getY(), screenWidth - 50, bounds.getHeight()); scenesDepthFrame.setBounds(bounds); } JList list = scrollTo.getList(depthLists); list.requestFocusInWindow(); list.setSelectedIndex(0); scenesDepthFrame.setVisible(true); // Must come before the setVisible method above scrollToTheLastList(scrollPane, scrollTo); }
private void scrollToTheLastList(JScrollPane scroll, ScrollTo to) { JScrollBar bar = scroll.getHorizontalScrollBar(); bar.setValue(to.equals(ScrollTo.last) ? bar.getMaximum() : bar.getMinimum()); }