java - Organizing JPanels and Layouts -


so have following screen:

screen

and code:

setlayout(new borderlayout());  jlabel lbltitulo = new jlabel("sistema generador de examenes");      lbltitulo.setfont(new font("tahoma", font.bold, 18));  jpanel panel1 = new jpanel(); panel1.setbackground(color.white); panel1.add(lbltitulo); add(panel1, borderlayout.north);  jbutton btncrear = new jbutton("crear examen"); jbutton btnrendir = new jbutton("rendir examen"); jbutton btncorregir = new jbutton("corregir examen"); jbutton btnvercorrecciones = new jbutton("ver correcciones");  btncrear.setbounds(15, 100, 450, 35); btnrendir.setbounds(15, 150, 450, 35); btncorregir.setbounds(15, 200, 450, 35); btnvercorrecciones.setbounds(15, 250, 450, 35);  jpanel panel2 = new jpanel(); panel2.setbackground(color.white); panel2.setlayout(null); panel2.add(btncrear); panel2.add(btnrendir); panel2.add(btncorregir); panel2.add(btnvercorrecciones);  add(panel2, borderlayout.center); 

1 - i'm using borderlayout. need have 2 jpanels separate components (jlabel , jbuttons) if want have jlabel in north , jbuttons in center? or there way use 1 jpanel?

2 - want take out setbounds used in jbuttons , use layout in order have jbuttons in middle of screen. how that?

i'm using borderlayout. need have 2 jpanels separate components (jlabel , jbuttons) if want have jlabel in north , jbuttons in center? or there way use 1 jpanel?

yes, use 1 jpanel , gridbaglayout single column , insets space buttons label.

however, nested layouts keep buttons in center no matter how resize jframe.

i want take out setbounds used in jbuttons , use layout in order have jbuttons in middle of screen. how that?

the gridbaglayout space out buttons insets.

see article, sudoku solver swing gui, couple of examples of dialogs use gridbaglayout.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -