> I am having this weird problem.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
> > I am having this weird problem.
>
[quoted text clipped - 6 lines]
> For tips on preparing that example, see..
> <http://www.physci.org/codes/sscce.jsp>
I am sorry about not providing sample code. Given below is what I am
doing.
In JApplet,
public void init() {
//some stuff...
scroller = new JScrollPane();
scroller.setOpaque(true);
scroller.getViewport().add(new MyJPanel());
scroller.setPreferredSize(new Dimension(800, 600));
getContentPane().add(scroller, BorderLayout.CENTER);
setVisible(true);
validate();
}
In MyJPanel,
public void paint(Graphics g) {
Dimension area = new Dimension(0,0);
Rectangle rect = new Rectangle(x,y,IMGW,IMGH);
g2d.drawImage(img,x,y,IMGW,IMGH,this);
scrollRectToVisible(rect);
int this_width = (x + W + 5);
if (this_width > area.width) {
area.width = this_width;
changed=true;
}
int this_height = (y + H + 50);
if (this_height > area.height) {
area.height = this_height;
changed=true;
}
if (changed) {
setPreferredSize(area);
scrollRectToVisible(new Rectangle(area.width, area.height, IMGW,
IMGH));
revalidate();
}
public void mouseDragged(MouseEvent e) {
x = e.getX();
y = e.getY();
/// some stuff...
// Dimension d stores the current dimensions of the BufferedImage
Rectangle r = new Rectangle(d.width-600, d.height-400,
d.width+100, d.height+100);
((JPanel)e.getSource()).scrollRectToVisible(r);
repaint();
}
public void mouseMoved(MouseEvent e) {
// some stuff...
repaint();
}
Once again, my problem is:
1) When I drag the image such that scrollbars appear, the display area
starts flickering. Other than the (stable)scrollbars already visible,
there is another set of scrollbars visible flickering in the middle of
the display.
2) The scrollbars fix the image at the rightmost lower corner and when
I try to move the scrollbars back or up, they move and then instantly
snap back to the original rightmost lower corner. Hence, not allowing
me to see anything other than the rightmost lower corner.
Please help.
Thanks,
losttemp
Andrew Thompson - 05 Nov 2004 03:50 GMT
>>> I am having this weird problem.
>>
[quoted text clipped - 12 lines]
> In JApplet,
> public void init() {
That does not compile. You do not seem to have read
the link very carefully.
Please go back and read it again, a hint is to discover what
each of the letters of SSCCE mean ..and how many of them your
code sample did not fit.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane