java - Allignment of elements on JFrame -
here code excerpt
jbutton browse,upload; jpanel panel; jlabel username,path; final jtextfield usernametext,pathtext; final jtextarea statustext; inputwindow() { username = new jlabel(); username.settext("username:"); usernametext = new jtextfield(15); startdate = new jlabel(); startdate.settext("start date :"); startdatetext = new jpasswordfield(15); path = new jlabel(); path.settext("file path :"); pathtext = new jpasswordfield(15); browse=new jbutton("browse.."); upload=new jbutton("upload.."); statustext = new jtextarea(35, 35); }
how should add jframe
or jpanel
align in folowing ways
- row 1 ---> username , username text
- row 2 ---> startdate , startdatetext
- row 3 ---> path, pathtext, browse , upload
- row 4 ---> statustext
i have though time aligning elements. please guide.
not best way, easiest understandable way!
put want in row in 1 jtable, example:
jpanel row1 = new jpanel(); row1.add(username); row1.add(usernametext); ...
and on! reason behind is, if put them on jpanel easier place on grid. if have done that, use gridlayout jframe.
jframe frame = new jframe(new gridlayout(4, 1));
the "4" rows , "1" columns! have add jpanels jframe, like:
frame.add(row1); frame.add(row2);
keep in mind that not best solution! there ways too, not need panels. example grouplayout best thing. if want see layouts, can here. explained here, because think easiest understandable way.
Comments
Post a Comment