P
pek
Currently I have a CardGroupPanel that extends JScrollPane (because I
want it to be scrollable).
This CardGroupPanel has a JPanel named Container. The Container has a
number of CardLabels that are components that extend JLabel and draw a
Playing Card. CardGroupLabel also has a LinkedList<Card> cards.
CardGroupPanel has a method addCards(LinkedList<Card> someCards) which
adds someCards to cards and creates for each Card a CardLabel
(basically a wrapper for each Card) which then is added to Container.
CardGroupPanel also has an option for Card Orientation (Horizontal or
Vertical). Depending on the orientation, the cards are drawn
accordingly.
Suppose that I create a CardGroupPanel with Horizontal orientation.
The CardGroupPanel has width 200 (depends from the size of the
JFrame). The CardLabels width is about 20. This means that
CardGroupPanel can draw fully, 10 CardLabels. After that, the vertical
scroll bar will appear.
The problem is that I want, when Horizontal orientation is selected,
the 11th card will be drawn UNDER the first card creating a second row
of cards. Thus, HORIZONTAL SCOLL BAR will be activated. Same with
Vertical orientation, I would like to create a second column of cards
and activate the horizontal scroll bar.
The problem is that by default, the size of Container is not set.
Calling container.getSize(), container.getMinimumSize() and
getPreferredSize() will get 0x0 and getMaximumSize() will get
something like 31000x20000. That means that I cannot use the
containers size to calculate exactly WHEN to create a second row or
column. I don't want to explicitly set the size because if the JFrame
is resized, it should automatically calculate the rows and columns of
the new size it has.
Any ideas?
I hope everything is clear. Thank you.
Sorry for my English.
want it to be scrollable).
This CardGroupPanel has a JPanel named Container. The Container has a
number of CardLabels that are components that extend JLabel and draw a
Playing Card. CardGroupLabel also has a LinkedList<Card> cards.
CardGroupPanel has a method addCards(LinkedList<Card> someCards) which
adds someCards to cards and creates for each Card a CardLabel
(basically a wrapper for each Card) which then is added to Container.
CardGroupPanel also has an option for Card Orientation (Horizontal or
Vertical). Depending on the orientation, the cards are drawn
accordingly.
Suppose that I create a CardGroupPanel with Horizontal orientation.
The CardGroupPanel has width 200 (depends from the size of the
JFrame). The CardLabels width is about 20. This means that
CardGroupPanel can draw fully, 10 CardLabels. After that, the vertical
scroll bar will appear.
The problem is that I want, when Horizontal orientation is selected,
the 11th card will be drawn UNDER the first card creating a second row
of cards. Thus, HORIZONTAL SCOLL BAR will be activated. Same with
Vertical orientation, I would like to create a second column of cards
and activate the horizontal scroll bar.
The problem is that by default, the size of Container is not set.
Calling container.getSize(), container.getMinimumSize() and
getPreferredSize() will get 0x0 and getMaximumSize() will get
something like 31000x20000. That means that I cannot use the
containers size to calculate exactly WHEN to create a second row or
column. I don't want to explicitly set the size because if the JFrame
is resized, it should automatically calculate the rows and columns of
the new size it has.
Any ideas?
I hope everything is clear. Thank you.
Sorry for my English.