当我尝试在Point2D对象上使用setLocation()方法时,我总是得到一个NullPointerException。我的代码中有6或7个Point2D对象,它只抛出这个对象的异常。下面是代码片段:
导入java.awt.geom.*;
public class Box
{
private Point2D coord;
private int height;
private int width;
public Box()
{
coord.setLocation(0,0);
height = 40;
width = 200;
}
..。
并在此处创建对象:
public MainGUI()
{
frame = new JFrame();
view = new ViewPanel();
controls = new ControlPanel();
ballAction = new Ball();
boxAction = new Box();
springAction = new Spring();
有什么想法吗?谢谢!
https://stackoverflow.com/questions/23179139
复制相似问题