Click to See Complete Forum and Search --> : JTabbedPane won't keep size


nanode
10-10-2000, 12:13 PM
A code snippet is best to explain:


public class NotebookTab extends JPanel {

private JTabbedPane jtp = new JTabbedPane();

public NoteBookTab() {
this.add(jtp);
}
...


That's condensed quite a bit, I get a JPanel w/ a JTabbedPane upon construction.

Also in this class is a changeSize method:


private void changeSize(int w, int h) {
Dimension tmpDim = jtp.getSize();
jtp.setSize(tmpDim.width + w, tmpDim.height + h);

}



The changeSize mehtod works great, but the dimensions get tossed out and return to the default size when I change tabs.

I even added a few instances of this to a JPanel - and changing tabs resizes all instances of this class back to their default size.

Any ideas how to prevent this?

Dru Lee Parsec
10-10-2000, 04:03 PM
You need to change the size of the JPanel that contains jtp. Every time you change tabs it will calculate it's size depending on the size of it's container. (which is exactly what your are seening).

If you absoulutly must have the tab pane change size then put it inside an "invisible JPanel" (no border) and then resize that instead.

nanode
10-10-2000, 05:37 PM
Ahhh,

My JPanel that you suggest resizing is inside a gridLayout of another panel http://www.linuxnewbie.org/ubb/smile.gif Must rethink a bit.


I'll likely end up throwing this out the window, but I am learning a lot in the process.

thanks