-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 1.2.0
-
Component/s: client-libs
-
1.2beta4
-
sparc
-
solaris_2.6
-
Verified
JScrollPane.setViewportView doesn't return graphics to correct view. If the app is maximized, and then returned to its original size, (two double clicks in succession in the window's title bar) it looks the icon graphics do not return to where they were before the maximization. This occurs with JDK1.1.6 and swing-1.0.2 on Solaris 2.6.
Steps to Reproduce:
0) Run the code below with the configuration above.
1) Note the very first view.
2) Maximize the window.
3) Minimize the window back to the original view.
RESULT: The icon graphics are not returned the their original locations.
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class viewport2 extends JFrame {
viewport2() {
JScrollPane scrollPane = new JScrollPane();
JPanel panel = new ScrollablePanel();
for(int i=0; i < 20; ++i) {
panel.add(new JLabel(new ImageIcon("two_cents.gif"))); }
panel.setBorder(BorderFactory.createLineBorder(Color.black, 2));
panel.setPreferredSize(new Dimension(200,200));
scrollPane.setViewportView(panel);
getContentPane().add(scrollPane);
pack();
setVisible(true);
}
class ScrollablePanel extends JPanel implements Scrollable {
public void paint(Graphics g) {
super.paint(g);
System.out.println("size: " + getSize());
System.out.println("pref size: " + getPreferredSize());
}
public boolean getScrollableTracksViewportWidth() {
return false;}
public boolean getScrollableTracksViewportHeight() {return false;}
public int getScrollableBlockIncrement(Rectangle r, int orientation, int direction) { return 100;}
public int getScrollableUnitIncrement(Rectangle r, int orientation,int direction) {return 10;}
public Dimension getPreferredScrollableViewportSize() {return getPreferredSize(); }
}
public void windowClosing(WindowEvent e) {System.exit(0);}
public static void main( String[] argv ) {
JFrame frame = new viewport2(); }
}
Steps to Reproduce:
0) Run the code below with the configuration above.
1) Note the very first view.
2) Maximize the window.
3) Minimize the window back to the original view.
RESULT: The icon graphics are not returned the their original locations.
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class viewport2 extends JFrame {
viewport2() {
JScrollPane scrollPane = new JScrollPane();
JPanel panel = new ScrollablePanel();
for(int i=0; i < 20; ++i) {
panel.add(new JLabel(new ImageIcon("two_cents.gif"))); }
panel.setBorder(BorderFactory.createLineBorder(Color.black, 2));
panel.setPreferredSize(new Dimension(200,200));
scrollPane.setViewportView(panel);
getContentPane().add(scrollPane);
pack();
setVisible(true);
}
class ScrollablePanel extends JPanel implements Scrollable {
public void paint(Graphics g) {
super.paint(g);
System.out.println("size: " + getSize());
System.out.println("pref size: " + getPreferredSize());
}
public boolean getScrollableTracksViewportWidth() {
return false;}
public boolean getScrollableTracksViewportHeight() {return false;}
public int getScrollableBlockIncrement(Rectangle r, int orientation, int direction) { return 100;}
public int getScrollableUnitIncrement(Rectangle r, int orientation,int direction) {return 10;}
public Dimension getPreferredScrollableViewportSize() {return getPreferredSize(); }
}
public void windowClosing(WindowEvent e) {System.exit(0);}
public static void main( String[] argv ) {
JFrame frame = new viewport2(); }
}