java - JButton Layout set -


in code, okbutton in bad appear, large , long, how fix problem?

public class d7table extends jframe {  public jtable table; public jbutton okbutton;  public d7table() {          table = new jtable(mytablemodel(res));         okbutton = new jbutton("ok");      add(new jscrollpane(table), borderlayout.center);     add(okbutton, borderlayout.page_end);      this.setdefaultcloseoperation(jframe.exit_on_close);     this.setsize(800, 600);     this.setlocation(300, 60);     this.setvisible(true); }  public static void main(string[] args) {     swingutilities.invokelater(new runnable() {         @override         public void run() {             new d7table();         }     }); } } 

i remove irrelevant codes. enter image description here

you've added button south position of bordrlayout. default behaviour of borderlayout.

it fix it, create jpanel, add button it, add panel south position instead

take at

the approach mentioned above commonly known compound layouts, use series of containers different layout managers achieve desired effect.

jpanel buttonpane = new jpanel(); // flowlayout default jbutton okaybutton = new jbutton("ok"); buttonpanel.add(okaybutton); add(okaybutton, borderlayout.south); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -