java - accessing gridLayout grids -
so i'm using borderlayout panel girdlayout center position, have added objects gridlayout latter on add more information same grids.
private jframe frame; private jpanel mainpanel; static private jpanel centerpanel; public void loadplayer(player player){ int count = 1; centerpanel = new jpanel(new gridlayout(1,3)); (item i: player.getallitems()){ jpanel jpi= new jpanel(); jlabel jlitem= new jlabel(i.getname()); borderlayout bl = (borderlayout) (mainpanel.getlayout()) ; jpi.add(jlitem); jpi.setborder(borderfactory.createlineborder(color.black)); centerpanel.add(jpi); mainpanel.add(centerpanel,borderlayout.center); } my initial thoughts add 3 jpanel properties class , append when need be. sensible idea? or there more efficient/effective way of doing this.
thanks!
what mean "add more information same grids."? mean wish able alter information stored inside of 3 jpanels? or want able remove current jpanels , add new ones needed?
it seems want update jpanels stored player's information changes. in case, declare jpanels outside of loop (where declare jframe , main panel).
Comments
Post a Comment