eclipse - 在 JPanel 中绘图

标签 eclipse swing netbeans java

我已经声明了我的类(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/

相关文章:

java - 从 Eclipse View 调用 Xtext 生成器

java - 测试不工作

eclipse Mercurial插件安装错误

java - 按钮未正确排列

java - 如何在 Java 面板中使用网格布局?

java - 如何从不同的类将 JPanel 添加到 JFrame

java - 快速简单 : why won't this run?

java - Netbeans jar 文件图标问题

eclipse - 避免使用 Hibernate 生成工具生成标题注释

java - 单击 JButton 并打开 file.java