Java GUI.

Soldato
Joined
26 Nov 2005
Posts
3,839
Location
Doon the Bay (Newcastle)
I'm a beginner and i'm really struggling with the layout of a GUI.

I can't get my data panels to line up properly.

Instead of something like this:

Nights (label): [textbox]

Forname (label): [textbox]

Surname (label): [textbox]

Then a big output box with a label near it i'm getting 3 labels in a row, then the 3 input boxes.

I can't seem to convert my GUI in to grid layout, currently i'm using the NSEW border layout as that's all i know, and not very well either.

That layout works well for the positioning of my radio buttons (center) and my button panel (south) but North for the data panel just doesn't do it. :(

On top of that when one of the radio buttons is selected, i need another set of radio buttons or pref data panels to pop up and dissapear again when the buttons isn't selected.

Does anyone know what i should be doing here?

Many thanks.
 
Java GUI arrangement is nasty :S

Try splitting it into a gridlayout first, 2 wide
Then put the labels into the left one, and textboxes into the right.
 
Java GUI arrangement is nasty :S

Try splitting it into a gridlayout first, 2 wide
Then put the labels into the left one, and textboxes into the right.

Hi,

Thanks, i hope i'm not being cheeky but could you give a working example.

I just need to see it working first, then i can learn from it.

Thanks.
 
Code:
Label l = new Label("Name");
TextField t = new TextField();
Frame f = new Frame("My Frame");
Panel p = new Panel(new GridLayout(rows,columns));
p.add(l);
p.add(t);
f.add(p);

Won't be exactly what you're looking for, but that's how it's done
 
Last edited:
This is where an IDE like Netbeans is really useful with its drag and drop elements for GUI placement.

Quoted for truth, Eclipse has a visual editor option as well (I think you have to install it separately as it doesn't come with Eclipse by default). If you're going to be developing quite a few Java Apps with GUI's then it's certainly the way to go. JBuilder and Netbeans are other options too. But honestly an IDE is definitely the way to go.
 
So these apps allow me to drag and drop where i want things to go, without coding?

Does it generate the needed code so i can edit it in something such as blue J, or copy and paste the code in to my project?

Also are they free?

Thanks
 
So these apps allow me to drag and drop where i want things to go, without coding?

Does it generate the needed code so i can edit it in something such as blue J, or copy and paste the code in to my project?

Also are they free?

Thanks

Yes, basically you can set a NULL layout then drag, drop, resize etc components. Each time you make an alteration the code is auto generated. The draw back is that the code is usually junk, but it's a fast way to make a decent looking front end. You can copy it out of course into anything, but be warned if you go down the JBuilder route I think it adds from of it's own libraries where as the Eclipse one uses standard stuff.

EDIT Yes netbeans and eclipse are free, JBuilder isn't though.
 
Cool, can't install here at college, will have to wait until i get home to have a play about with that one.

Will such programs allow me to select a radio button and then produce other text feild options when selected, and hide when another radion button option is selected? (as that was my other query for code, but if that can do it then i'm quite happy to use that)

Get that sorted and i just need to somehow link up my working classes to the GUI. God i hate Java. :(
 
Cool, can't install here at college, will have to wait until i get home to have a play about with that one.

Will such programs allow me to select a radio button and then produce other text feild options when selected, and hide when another radion button option is selected? (as that was my other query for code, but if that can do it then i'm quite happy to use that)

Get that sorted and i just need to somehow link up my working classes to the GUI. God i hate Java. :(

I hate Java too! And yes that should be fine, though I'm not 100% sure what your on about. Personally I prefer Eclispe, but for visual stuff Netbeans might actually be a better option. Plus loads of us I guess use either Eclipse or Netbeans so you can post questions if you get stuck (the same will be true on any Java programming boards too).
 
Good luck with it Dokko, I'm doing a Java gui building assignment at the moment and it's blooming confusing.
Most references seem to suggest using a drag and drop IDE, but we're banned from doing that for this assignment : (
 
Back
Top Bottom