Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help in layout managers.  RSS feed

 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm implementing a code in that I have to use Swing. Please help regarding layouts.

I have to show a dialog in that I have to show one panel and in panel I'm going to use different cards.

so for dialog which layout I should use to hold the panel.

In cards I have to show buttons at particular location say X,Y coordinate. so which layout will support this kind of behavior for displaying the buttons at particular location.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the Swing tutorial, it has a secton on "Using Layout Managers". It sounds like a CardLayout would be a place to start.
 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which layout should I use to show buttons at different location.
I'm not getting any solution for that
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really must hard code the coordinates (which is usually a terrible idea because it will fail when you scale the UI) setting the layout manager to null, then calling setBounds on each separate component helps. Don't forget to set the preferred size manually as well.
 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to read coordinates from XML file so it wont be a problem for that.
thanks for your suggestion
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which layout should I use to show buttons at different location.


Have you read the tutorial yet? The tutorial describes using LayoutManagers as well as using Absolute Positioning.

I see, why bother read the tutorial, if you just keep asking for help someone will spoon feed the answer. The problem is the next time you have a question you won't bother reading the tutorial again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!