i have an app that resizes the JFrame to fit the size of the image displayed in a JPanel. i decided to add a JScrollPane so it can display images that are larger than the screen(it cropped them). it works but the frame is a little too big and you cant see the horizontal scrollbar and only half of the vertical one. if i click the maximize button in the title bar, it displays correctly. how to correct this?
noticed i forgot to call super.paintComponent(g) but it worked anyway.
anyway adding that line had no effect.
FYI for anyone who cares. i tried Rob's suggestion about not needing to call repaint(). it worked at first(when files were different size). but when i opened files the same size(my documents/my pictures/sample pictures), pack() didn't call repaint(). in fact pack didn't get called because the size was the same. so i needed to call repaint() after all.
Joined: Jun 13, 2009
If you use a JLabel and reset the Icon there is no need to call repaint() because the setIcon() method calls repaint().