• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

converting borderlayout

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic