java - DrawLine over GridBagLayout shows nothing -


i have mappanel class extends jpanel. display objects in grid , want of them linked line. trying draw lines mappanel.paintcomponent no line has been shown. check line parameters (x1,y1,x2,y2) system.out.println() , right ( kind of 0 < param < 600, measures fit panel). try draw 1 line fixed parameters have same problem.

public class newmappanel extends jpanel {      private static final long serialversionuid = 1l;      private gamemap gamemap;     private grid grid;     private jpanel contentpanel;      public newmappanel() {         this.setbackground(color.white);     }      public void updatemap(gamemap gamemap) {         this.gamemap = gamemap;          ...load object custom object grid ...          contentpanel = new jpanel(new gridbaglayout());         contentpanel.setbackground(color.green);         gridbagconstraints c = new gridbagconstraints();          // draw grid         (city city : gamemap.getcities().values()) {             citypanel citypanel = new citypanel(city, grid);              c = new gridbagconstraints();             c.gridx = grid.getcolumn(city);             c.gridy = grid.getrow(city);             c.gridwidth = 1;             c.gridheight = 1;             c.fill = gridbagconstraints.both;             c.anchor = gridbagconstraints.center;              contentpanel.add(citypanel, c);         }          add(contentpanel, borderlayout.center);     }       @override     public void paintcomponent(graphics g) {         super.paintcomponent(g);          contentpanel.setsize(super.getwidth(), super.getheight());         grid.setsize(super.getwidth(), super.getheight()); //to right parameters used drawline           (city city1 : gamemap.getcities().values()) {             int x1 = grid.getbarycenterx(city1);             int y1 = grid.getbarycentery(city1);             (city city2 : city1.getadjacentcities()) {                 int x2 = grid.getbarycenterx(city2);                 int y2 = grid.getbarycentery(city2);                  system.out.println("(" + x1 + "," + y1 + ") -> (" + x2 + "," + y2 + ")");                 g.drawline(x1, y1, x2, y2);              }         }       }  } 

have tried set color? g.setcolor(color.black);


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -