This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes problem with layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with layout" Watch "problem with layout" New topic
Author

problem with layout

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
I am new to swing programming. I am trying to create a layout for a small Examination. It should be in the following manner
_______________________________________________________________
Question 1 : <Here comes the Question>

* <Option a radio button>
* <Option a radio button>
* <Option a radio button>

|SUBMIT BUTTON|
_______________________________________________________________

here is the code that i wrote to create such a layout



I am not getting the color right, niether are the components are arranged properly, even the border that should be around the JPanel sorrounds the radio button option.

i am unable to why is this happening

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Try this. Identify the differences, and tell us what was going wrong



[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Muzaffar Shah Khan
Greenhorn

Joined: Feb 13, 2010
Posts: 7
You have to use Flow Layout in which each component should be in horizontal Box
then again add each box in Vertical Box then set this vertical box to Flow layout.
For example
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
my question revolves around the GridLayout.why is the GridLayout not taking the vertical gaps.



please check out this code



The distance between two labels is not effected by the 3rd and 4th argument in the constructor

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> The distance between two labels is not effected by the 3rd and 4th argument in the constructor

it is, put a border around each label, and you'll see it.

re-read the GridLayout docs to understand your problem
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
Thanks i got it.
 
 
subject: problem with layout
 
Similar Threads
Visibility help?
can get label on second line
Problem with radio button
missing components
To many Frames