• 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

Swing components

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 3 swing components text field, combo box and a text field and want to display them in that order each on one line.
I am not able to figure out Swing equivalent of text new line.
I tried fiddling with Layout manager, but I think I am doing something wrong.
Any ideas or pointers would be helpful.
Thanks
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several approaches. You should add these components to a container of some kind (try a JPanel). For three items, you can set the layout to BorderLayout and add each one to a different region (there are 5 - North, South, East, West and Center)...
Try something like this:
JPanel panel = new JPanel(new BorderLayout());
panel.add(myTextField1, BorderLayout.NORTH);
panel.add(myCombo, BorderLayout.CENTER);
panel.add(myTextField2, BorderLayout.SOUTH);


Be sure to add the panel to your JFrame with
getContentPane().add(panel);
pack();
show();
Hope this helps...
[ October 30, 2002: Message edited by: Gil Estes ]
 
Roberto Diaz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works just fine.
Thanks.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic