java - Idea gui programming (in form) -
i'm trying nice gui form in intellij. i'm using gridlayoutmanager(intellij). possible this?
| button | buttton | | | ________|________ here combobox
i m not sure expect, can try example:
jframe frame = new jframe(); jpanel panel = new jpanel(); jbutton button1 = new jbutton("1"); jbutton button2 = new jbutton("2"); jcombobox combo = new jcombobox(); panel.setlayout(new gridlayout(1,2)); panel.add(button1); panel.add(button2); frame.add(panel); frame.getcontentpane().add(borderlayout.south,combo);
you can use gridlayout in panel, , add frames borderlayout. can use gridlayouts:
jpanel panel = new jpanel(); jpanel innerpanel = new jpanel(); jbutton button1 = new jbutton("1"); jbutton button2 = new jbutton("2"); jcombobox combo = new jcombobox(); panel.setlayout(new gridlayout(2,1)); innerpanel.setlayout(new gridlayout(1,2)); innerpanel.add(button1); innerpanel.add(button2); panel.add(innerpanel); panel.add(combo);
here use 1 panel gridlayout, within panel gridlayout. effect should same. not elegant ways that. better if learn use gridbaglayout (https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html). more flexible layout.
Comments
Post a Comment