在Netbeans 8表单设计师的早期非法尝试退出

时间:2015-03-31 21:28:41

标签: java swing netbeans awt netbeans-8

我对Netbeans无法在图形设计器中渲染表单感到困惑。当我运行应用程序时,窗口和组件显示正常,如下所示:

但是,尝试在设计器中显示相同的窗口会导致:

我无法确定问题,特别是考虑到程序在运行时有效。是什么给了什么?

编辑:怀疑有错误的代码。

public void paint(Graphics g) {
    log.trace("Painting...");
    Graphics2D g2 = (Graphics2D) g;

    g2.setStroke(new BasicStroke(0.0f)); // hairline

    AffineTransform transformer = new AffineTransform();
    transformer.scale(scale, scale);

    g2.setTransform(transformer);

    // TODO: Actual selection using the combobox in the frame.
    Collection<GravPoint> list = null;
    for (StarSystem s: GameState.inst().systems) {
        if (list == null)
            list = s.getCelestialObjects();
    }

    // Get the largest orbit.
    double maxOrbit =1;
    for (GravPoint gp: list) {
        if (gp.getOrbit() > maxOrbit)
            maxOrbit = gp.getOrbit();
        //log.debug(gp.getName() + " " + gp.getOrbit());
    }
    //log.debug("maxOrbit = "+maxOrbit);

    double x, y;
    double orbit;
    for (GravPoint s: list) {
        // TODO: urgh, can't this draw double-coordinates?
        // center.
        // The orbital path.
        orbit = 200*s.getOrbit()/maxOrbit;
        g2.drawOval((int)(center.x/scale)-(int)orbit+1,(int)(center.y/scale)-(int)orbit+1, (int)orbit*2, (int)orbit*2);
        // The body.
        x = center.x/scale + 200*s.getX()/maxOrbit;
        y = center.y/scale + 200*s.getY()/maxOrbit;
        g2.drawOval((int)x, (int)y , 3, 3);
        // The label.
        g2.drawString(s.getName() + "("+(int)x+","+(int)y+")", (float)x+10, (float)y+10);
        g2.drawString("x" + "("+center.x+","+center.y+")", (float)(center.x/scale), (float)(center.y/scale));
        log.trace("Printing "+s.getName()+" at "+s.getX()+","+s.getY());
    }
    log.trace("Done painting.");
}

0 个答案:

没有答案