[vtkusers] resizing vtkPanel

JL jclopez+vtk at andrew.cmu.edu
Mon Apr 22 20:07:57 EDT 2002


Hi Liya,

My guess is that the problem is an obscure interaction between
JFC components and vtkPanel.  I bet that the Tabbed Pane is
calling vtkPanel's setBounds(...) (or other) method directly
and not setSize(...).

If I'm not mistaken, all the position / size methods (i.e.,
setSize, resize (deprecated), locate (deprecated), reshape
(deprecated), setLocation and even setBounds) ultimately end up
in a call to setBounds(int x, int y, int width, int height).
What this means is that vtkPanel should override the
setBounds(int x, int y, int width, int height) instead of the
setSize(int width, int height) method.

Unfortunately the java AWT/JFC documentation isn't clear,
probably for valid reasons, about what method one should
override to obtain the desired behavior.  The way one can find
about this 'feature' is to look at the java.awt.Component code.

Actually, it is probably a good idea not to rely on an obscure,
and maybe implementation dependent, feature.  Instead a more
general approach should be used.  For example, vtkPanel could
override all methods that could potentially change its size
and / or location.

In such approach, in order to override one of these methods,
one would do something like:

  public void setSize(int width, int height)
  {
    super.setSize(width, height);
    this.SetSizeInternal(this.rw, width, height);
  }

  public void setBounds(int x, int y, int width, int height)
  {
    super.setBounds(x, y, width, height);
    this.SetSizeInternal(this.rw, width, height);
  }

but the call to the parent's setSize(width, height) eventually
results in a call this.setBounds(x,y,w,h), which means,
this.setSizeInternal would get called more than once.
Of course, in this case, the fact that this.SetSizeInternal(...)
is called several times does not affect correctness, and it
probably will have no real impact on performance.

I hope this helps (somewhat),

-- Julio

-----Original Message-----
From: vtkusers-admin at public.kitware.com
[mailto:vtkusers-admin at public.kitware.com]On Behalf Of Liya Chernyakova
Sent: Monday, April 22, 2002 3:52 PM
To: vtkusers at public.kitware.com
Subject: [vtkusers] resizing vtkPanel


I am having trouble resizing vtkPanel.
I have vtkPanel added to JPane, which itself is added to the Tabbed Pane.
When I am trying to move Tabbed Pane border from left to right
nothing happens (vtkPanel window does not become smaller) while moving from
right to left works OK. When I am trying to move the right
border, instead of resizing the window it moves the whole pichture to the
left.
Does anybody know/ suggests solution to this problem?
Thank you,
Liya Chernyakova
Simulation Technology & Applied Research, Inc.
11520 N. Port Washington Rd.
Suite 101 B
Mequon, WI  53092
Phone: (262) 240-0291 ext.104
FAX: (262) 240-0294
e-mail: liya.chernyakova at staarinc.com
web: http://www.staarinc.com




More information about the vtkusers mailing list