|
-
May 29th, 2003, 09:06 AM
#1
Thread Starter
Lively Member
setSize()
i've got a container, containing a menubar and a cardlayout. the cardlayout holds a couple of 'cards' (JPanels).
these JPanels vary in size (one contains only 2 buttons), but i don't want to have to use setSize() everytime i switch from card to card.
shouldn't the container frame dynamically adjust its size so that each JPanel is displayed appropriately? (i.e. the smaller JPanel would cause the frame to be smaller, just enough for all the JPanel's components to be displayed etc)
-
May 29th, 2003, 12:45 PM
#2
Dazed Member
Just for clarification purposes. Do you have the JMenuBar hooked to the root component using setJMenuBar() in JRootPane?
Now to switch from card to card you do not need to use setSize(). That is not what that method was intended for. You use these methods to loop through the stack of cards.
void first(Container parent)
void next(Container parent)
void previous(Container parent)
void last(Container parent)
Or to show a specific card.
void show(Container parent, String name)
-
May 29th, 2003, 08:45 PM
#3
Thread Starter
Lively Member
yes i do have a JMenuBar set using setJMenuBar();
Container c = getContentPane();
cardManager = newCardLayout;
deck.setLayout(cardManager);
JPanel card1 = new JPanel();
JPanel card2 = new JPanel();
deck.add(card1, "card1");
deck.add(card2, "card2");
c.add(deck);
show();
my problem is that when i do flip through the cards using first, next, show etc, the size of the entire frame (window) stays the same. i was hoping that it would change depending on the size of the panel in each of the cards.
i tried first setting the frame size: setSize(250,90);
then when a button is clicked:
if (e.getSource() == jbNS) {
cardManager.show(deck, "card2");
setSize(535,210);
show();
}
this seems to work, the frame's size would be that of 535, 210, and components of card2 will not be displayed correctly. but i would've thought that there's some way i could make java resize the frame depending on the card selected...
Last edited by quipy; May 30th, 2003 at 01:58 AM.
-
Jun 2nd, 2003, 01:39 AM
#4
Wouldn't that look terrible anyway?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|