【发布时间】:2011-03-25 08:30:52
【问题描述】:
我制作了一个带有一些面板的小程序。
我用我创建的特定方法在面板上绘制了一些东西,它们使用图形对象进行绘制。
要绘制,我使用如下命令:
gr = this.getGraphics;
gr.drawString... etc
然后我从小程序类中调用这些方法。
我的问题如下:在我最小化或调整浏览器窗口大小后,面板没有
显示任何东西,我想是因为我没有在面板的paint() 方法中实现任何东西。
有没有办法在不改变我所有方法的情况下解决这个问题?
我的一些方法是这样的:
//paint a node with coords x,y and nodeNumber in the center of the node
public void paintNode(int x,int y,Integer numberOfNode){
gr = this.getGraphics();
gr.setColor(ShowGUI.getPanelColor());
gr.fillOval(x,y,40,40);
gr.setColor(Color.BLACK);
gr.drawOval(x,y,40,40);
gr.drawString(numberOfNode.toString(),x+17,y+25);
}
//marks red the processing edge
public void markEdge(int x1,int y1,int x2,int y2,Integer numberOfNode1,Integer numberOfNode2,int weight){
gr.setColor(Color.red);
this.paintEdge(x1,y1,x2,y2,numberOfNode1,numberOfNode2,weight);
this.paintNode(x1, y1, numberOfNode1);
this.paintNode(x2, y2, numberOfNode2);
}
【问题讨论】: