This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting borderlayout

 
shaon husain
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, im having trouble using borderlayout, and how its beheaving,


this code produces

however i need it to look like this, but this is done by absolute positioning, and giving me a few problems later on the code:



if you could possibly write the code that would be very generous, but i dont mind examples showing how to do it, or what i can do to fix it
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You appear to be mixing the old names for the areas in BorderLayout and the new names. Use one or the other. I suggest you start by adding the panels in those positions only, and giving each panel a different colour. Then you can see where they sit. Then try adding the controls to those panels.
What layout are you giving the panels?
Why have you given the class a lower‑case name (pte)?
 
shaon husain
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You appear to be mixing the old names for the areas in BorderLayout and the new names. Use one or the other. I suggest you start by adding the panels in those positions only, and giving each panel a different colour. Then you can see where they sit. Then try adding the controls to those panels.
What layout are you giving the panels?
Why have you given the class a lower‑case name (pte)?


what are the old and new borderlayout styles?
also what do you mean giving the layout a panel?
 
Rob Camick
Ranch Hand
Posts: 2534
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are the old and new borderlayout styles?


The old style uses compass directions (NORTH, SOUTH...). The new style uses PAGE..., LINE... See the Swing tutorial on Using Border Layout for more information. Also, download the example and use the structure of that program for your project. You should not be extending JFrame to build the GUI and code should execute on the EDT.

also what do you mean giving the layout a panel?


By default a JPanel uses a FlowLayout. You will probably need to change the layout on one or two panels to achieve your desired layout. Experiment with the different layout managers.

Also, don't use TextArea. Use JTextArea.
 
shaon husain
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
what are the old and new borderlayout styles?


The old style uses compass directions (NORTH, SOUTH...). The new style uses PAGE..., LINE... See the Swing tutorial on Using Border Layout for more information. Also, download the example and use the structure of that program for your project. You should not be extending JFrame to build the GUI and code should execute on the EDT.

also what do you mean giving the layout a panel?


By default a JPanel uses a FlowLayout. You will probably need to change the layout on one or two panels to achieve your desired layout. Experiment with the different layout managers.

Also, don't use TextArea. Use JTextArea.


thanks for your help, really appreciate it, take some time to get used to it though,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic