Re: JScrollBar Repaint Question
- From: "mearvk" <mearvk@xxxxxxxxx>
- Date: 28 Dec 2006 02:33:39 -0800
While working on some sandbox code to post here I was unable to get the
same glitch to manifest itself. What I discovered after closer
examination was this:
public void paintComponent(Graphics g)
{
//textPane.setSize(getWidth()-30,getHeight()-150);
scrollPane.setSize(getWidth()-30,getHeight()-150);
textField.setSize(getWidth()-30,25);
textField.setLocation(10,textPane.getHeight()+20);
send.setLocation(getWidth()/2,textField.getY()+35);
cancel.setLocation(getWidth()/2-110,textField.getY()+35);
super.paintComponent(g);
}
I had overridden the JInternalFrame's paintComponent method (above),
and the commented line (then uncommented) was evidently resetting the
value of the attached JScrollPane's JScrollBar.
So, lessons learned:
1. Calling a repaint on the JScrollPane is sufficient for JComponent
resizing (one need not call the attached components as well).
2. Calling a repaint on the attached members of a JScrollPane seems
to reset the underlying JScrollBar's value.
Working code looks like:
public void paintComponent(Graphics g)
{
scrollPane.setSize(getWidth()-30,getHeight()-150);
textField.setSize(getWidth()-30,25);
textField.setLocation(10,getHeight()-130);
send.setLocation(getWidth()/2,textField.getY()+35);
cancel.setLocation(getWidth()/2-110,textField.getY()+35);
super.paintComponent(g);
}
Thanks for the interest/help Oliver.
.
- Follow-Ups:
- Re: JScrollBar Repaint Question
- From: Oliver Wong
- Re: JScrollBar Repaint Question
- From: Andrew Thompson
- Re: JScrollBar Repaint Question
- References:
- JScrollBar Repaint Question
- From: mearvk
- Re: JScrollBar Repaint Question
- From: mearvk
- Re: JScrollBar Repaint Question
- From: Oliver Wong
- Re: JScrollBar Repaint Question
- From: mearvk
- Re: JScrollBar Repaint Question
- From: Oliver Wong
- JScrollBar Repaint Question
- Prev by Date: JTextField - how to disable selecting text in this component?
- Next by Date: Re: JTextField - how to disable selecting text in this component?
- Previous by thread: Re: JScrollBar Repaint Question
- Next by thread: Re: JScrollBar Repaint Question
- Index(es):