java - Trying to get a Border near on JPanel but it's vanishing -


i have field of little jbuttons[15][30] (35px) , want border around field. thought it's enough write following:

 private void gamefield() {      fieldpanel = new jpanel();                      box box = box.createverticalbox();      gridbaglayout bag = new gridbaglayout();            fieldpanel.setlayout(bag);     gridbagconstraints gbc = new gridbagconstraints();       fieldpanel.setborder(new compoundborder(new emptyborder(50, 0, 0, 0), borderfactory.createlineborder(color.black)));     fieldpanel.setmaximumsize(new dimension(800, 500));     fieldpanel.setminimumsize(new dimension(800, 500));       box.add(fieldpanel);      (int line = 0; line < field.length; line++) {         (int column = 0; column < field[line].length; column++) {             field[line][column] = new jbutton();             field[line][column].setpreferredsize(new dimension(25, 25));                field[line][column].setopaque(true);             field[line][column].setcontentareafilled(false);             field[line][column].setborderpainted(true);             field[line][column].setenabled(false);              gbc.gridx = column;             gbc.gridy = line;             fieldpanel.add(field[line][column], gbc);          }     }      frame.add(box, borderlayout.center); } 

but result:

enter image description here

you see part of field of jbuttons, border maybe 10px high , wide.

for testing have placed red line nearby on left upper corner. , if place line few more pixel right going disappear. in other words if putting black border closer button field it's going vanishing. notices: i'm using gridbaglayout jpanel (which includes jbutton field) , wrapped box.

edit: it's snake , works (at moment). (only problem border exists, above). have added second image better explanation:

http://s10.postimg.org/76rffr2u1/unbenannt.jpg


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -