PDA

View Full Version : [SOLVED] Java help with LayoutManager



SpinningAround
December 28th, 2009, 04:03 PM
I'm working on a little program in Java that will monitor my traffic amount there is a few things left but at the moment I'm trying to find a way to setup the Layout so it get the Layout as seen in picture two in attachment. The first attachment show how it looks now with flowlayout.

doas777
December 28th, 2009, 04:06 PM
try a border layout. may be more what you need.

SpinningAround
December 28th, 2009, 04:12 PM
try a border layout. may be more what you need.
Might be possible but there are eight elements
JLabel
JTextField
JPanel
JLabel
JTextField
JLabel
JTextField
JPanel

kahumba
December 28th, 2009, 05:52 PM
I'd use a javax.swing.BoxLayout for the content pane and then add all the widgets, thus:
(1) The BoxLayout must do vertical layou (PAGE_LAYOUT)
(2) (Since we're dealing with BoxLayout) we need to have each widget's preferredSize etc. set up properly.
(3) Each object must be in the center: setAlignmentX(Component.CENTER_ALIGNMENT).

Attached example source code as a NetBeans ( 6.8 ) project and a screenshot.

kahumba
December 28th, 2009, 05:53 PM
Trying again to attach the screenshot.
Edit: oh nevermind, it's already there, looks like a glitch in the ubuntuforums.

SpinningAround
December 28th, 2009, 07:38 PM
Thanks solved it got it in a straight line now.