在嵌套 JPanel 的布局中,我希望添加一个绘制的椭圆。
为此,我使用以下内容:
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.GRAY);
g.fillOval(20, 20, 20, 20);
}
现在在我的一个面板中,我希望添加这个椭圆形,但我似乎无法添加它。
JPanel myPanel = new JPanel();
myPanel.setLayout(new GridLayout(0, 2));
//myPanel.add(...); here i wish to add the drawn oval
任何输入表示赞赏!