java - How to assign the location of button? -
how can create button on frame in north , in center horizontally? (i.e not occupy width)?
borderlayout
expands components in north
location fill width of container. therefore need place in container respects preferred size of component, jbutton
in case. can use default flowlayout
in jpanel
:
jpanel northpanel = new jpanel(); jbutton button = new jbutton("ok"); frame.add(northpanel, borderlayout.north);
Comments
Post a Comment