Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Card Layout issue  RSS feed

 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am making a peer to peer black Jack game and I am having trouble trying to figure out which layout will i use to stack cards so that each cards one end is seen and only teh last ones full card is seen .. Any Suggestions.


Regards,
Titus
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
probably the null layout, where you position the cards overlapping, making sure the 'fully visible' card is added last.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you should not use a null LayoutManager - the preferred size will not be calculated.

I provided some code in this thread that can help you implement a LayoutManager that does not layout the components (you'll need to call setBounds on them) but does calculate the preferred size.
 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you to both of you.. But i am confused with teh code Rob has pointed out. how exactly do i use it ? Ecuse me if that sounded lame but am kinda puzzled.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
minimumSize is the same as preferredSize but it uses getMinimumSize of the components instead of getPreferredSize.

You can then instantiate an instance of this class and use it with setLayout.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!