圆类不绘制圆 [英] Circle class not drawing circle
本文介绍了圆类不绘制圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Color.*;
public class Circle extends JPanel{
public void point(Graphics g){
setSize(500,500);
g.drawOval(100, 100, 100, 100);
}
public static void main (String [] args){
JFrame MainFrame = new JFrame();
MainFrame.setSize(600, 600);
Circle CirclePanel = new Circle();
MainFrame.add(CirclePanel);
MainFrame.setVisible(true);
}
}
我的尝试:
Jpanel空白没空圈
使用Eclipse for Java
What I have tried:
Jpanel come up blank no circle
using Eclipse for Java
推荐答案
好的,请按照主要方法代码进行操作。在任何时候你都没有调用point方法并传递Graphics上下文来绘制。
OK, so follow your Main method code. At no point do you ever call the point method and pass it Graphics context to draw on.
public void point(Graphics g){
这是一个简单的拼写错误。这个方法应该被称为 paint
,带有 a ,而不是点。
这篇关于圆类不绘制圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文