我已经声明了我的类(class):
public class myRightPanel extends JPanel
然后我像这样重写我的父类(super class)的paintComponent:
public void paintComponent(Graphics g){
super.paintComponents(g);
//Draw bunch of things here
}
现在事实证明我还需要一个方法,它接受两个整数(x,y)参数,并在该坐标处向我已经绘制的 myRightPanel
添加一些内容。当我已经覆盖了我的 paintComponent()
时,我该怎么做?
最佳答案
将 x,y 存储为 Point
作为类的属性,以便可以在 Paint 方法中访问它。调用repaint()
。
关于eclipse - 在 JPanel 中绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13414012/