Java Swing GridBagLayout -


i've been learning java swing using gridbaglayout.

i have main jframe , add main jpanel, add subsequent jpanels/components main jpanel.

but add it positions center of main panel (including while resize), not desired result.

just small snippet on core code:

getcontentpane().setlayout(new gridbaglayout()); jpanel panel = new jpanel(new gridbaglayout()); getcontentpane().add(panel);  gridbagconstraints gbc = new gridbagconstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = gridbagconstraints.northwest;  jtextfield namefield = new jtextfield(10); panel.add(namefield, gbc) 

any feedback appreciated, thanks.

in future, post sscce when have problem. small "snippet" of code doesn't help.

read section swing tutorial on how use gridbaglayout. part on "weightx/weighty" explain why happens.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -