• 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

formatting the GUI

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm creating a GUI to sit on top of some already existing code. I'm doing it by hand, and staying away from the Netbeans auto gen stuff, because quite frankly my experience is they cause more problems then they solve.

Regardless.

In this effort I'm trying to stick with with the basic layout structures (Border/Grid). I'm using GridBag in very SMALL Areas because quite frankly I can't seem to get things to go how/where I want them on any sort of bigger panel.

I'm having a hard time getting things (most notably JTextFields) to be the size i want them to be. What I have been doing to adjust for this is creating blank panels and inserting them as needed to shrink things down. For example I might want four JTextlabels and four TTextFields in the upper left quadrant of a panel, so I'll add those items to it's own panel using a Grid Layout (2,2) and add that panel to another grid layout on another panel (2,2) I would then add 3 blank panels as either placeholders for things in the future, or simply for the blank space.

Is this a bad/unacceptable practice? IS there something better I should be doing?

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bad/ unacceptable? not as far as i know. there are many other features of swing some others might help you with. you can use horizontal glue for instance to space something over to the other side with blank in the middle. you can also set the preferred size of components to make them smaller for instance.
 
Jason Richard
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would seem that Box Layout is going to be helpful as well. Oh why did I ignore thee to start??
 
Bring me the box labeled "thinking cap" ... and then read 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