JInternalFrame does not automatically resize when i add a row to a table

Posted on 2003-03-10
Medium Priority
Last Modified: 2010-05-19
Hi All,

When I add a row to a table, the JInternalFrame does not resize to accomodate this. Instead the JScrollPane viewport resizes and I get a vertical scroll bar.
Any ideas how to resolve this?
Thanks for looking
Question by:colin812
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 35

Expert Comment

ID: 8102807
Errrr....A ScrollPane is supposed to be there to stop the JInternalPane resizing, and add a Vertical scrollbar when you add rows to the table...

Expert Comment

ID: 8102887
If you really have to do this (as TimYates said, everything works as designed in your example), you have to do it manually everytime you add a row:

Recatangle formerbounds = internalframe.getBounds();
internalpane.reshape(formerbounds.x, formerbounds.y, table.getSize().width, formerbounds.height);

You may have to add some pixels to the width because there is always some margin.


Accepted Solution

karlika earned 150 total points
ID: 8102916
oh, sorry, you meant the height to adjust:

Recatangle formerbounds = internalframe.getBounds();
internalpane.reshape(formerbounds.x, formerbounds.y, formerbounds.width, table.getSize().height);

There you also have to add the size of the margin and all other components that are contained by this JInternalFrame

Author Comment

ID: 8104359
I gave the points to karlika for suggesting an alternative although both answers are correct,
many thanks to both of you,

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question