Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with layout

 
shukla raghav
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this. Identify the differences, and tell us what was going wrong

 
Muzaffar Shah Khan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic