向NetBeans GUI构建器添加自定义组件! (WorldWind) [英] Adding a custom component to NetBeans GUI builder! (WorldWind)

查看:157
本文介绍了向NetBeans GUI构建器添加自定义组件! (WorldWind)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我正在尝试将NASA的World Wind地球添加到由NetBeans GUI构建器创建的GUI窗口中.我的示例代码实例化了自己的窗口,GUI生成器希望我不要编辑将其滑入的必要区域:)我自己编写,但这是NetBeans平台应用程序的一部分,并且包含代码和注释Im尚未准备好处理呢.我不确定如何做到这一点.这是我在窗口中想要的示例代码:

Ok, I'm trying to add the World Wind globe from NASA to a GUI window created by NetBeans GUI builder. My sample code instantiates its own window, and the GUI builder would like me not to edit the areas necessary to slip this in :) I'd write my own but this is part of a NetBeans platform app and contains code and annotations Im not prepared to handle yet. I am not sure how to accomplish this. Here is the sample code I would like in the window:

public class WorldWindTest {

public static void main(String[] args) {

    //create a WorldWind main object
    WorldWindowGLCanvas worldWindCanvas = new WorldWindowGLCanvas();
    worldWindCanvas.setModel(new BasicModel());
            Position myPoint = Position.fromDegrees(31.12, -88.64, 35000);


    //build Java swing interface
    JFrame frame = new JFrame("World Wind");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(worldWindCanvas);
    frame.setSize(800,600);
    frame.setVisible(true);

    //create some "Position" to build a polyline
    LinkedList<Position> list = new LinkedList<Position>();

//          list.add(Position.fromDegrees(i,0.0,i*20000));
    }

            list.add(Position.fromDegrees(30.12, -85.64, 35000));
            list.add(Position.fromDegrees(31.12, -88.64, 35000));


    //create "Polyline" with list of "Position" and set color / thickness
    Polyline polyline = new Polyline(list);
    polyline.setColor(Color.RED);
    polyline.setLineWidth(3.0);

    //create a layer and add Polyline
    RenderableLayer layer = new RenderableLayer();
    layer.addRenderable(polyline);
    //add layer to WorldWind
    worldWindCanvas.getModel().getLayers().add(layer);
}
}   

推荐答案

为了扩大我的评论,我认为您可以创建一个名为SetUpWorldWindowGLCanvas的类,然后在其中初始化和设置WorldWindowGLCanvas对象,然后然后为它提供一个公共的getter方法,该方法将允许您获取已设置的WorldWindowGLCanvas对象.即

To amplify on my comment, I was thinking that you could create a class, say called SetUpWorldWindowGLCanvas, and in it, initialize and set up your WorldWindowGLCanvas object, and then give it a public getter method that would allow you to obtain the set up WorldWindowGLCanvas object. i.e.,

public class SetUpWorldWindowGLCanvas {

    WorldWindowGLCanvas worldWindCanvas = new WorldWindowGLCanvas();

    public SetUpWorldWindowGLCanvas() {
        worldWindCanvas.setModel(new BasicModel());
        Position myPoint = Position.fromDegrees(31.12, -88.64, 35000);

        // ... etc
    }

    public WorldWindowGLCanvas getWwGlCanvas() {
        return worldWindCanvas;
    }
}

然后将这个BorderLayout.CENTER放置在您的GUI构建器中创建的并且使用BorderLayout作为其布局管理器的JPanel中.

And then place this BorderLayout.CENTER in a JPanel that was created in your GUI builder and that uses BorderLayout as its layout manager.

这篇关于向NetBeans GUI构建器添加自定义组件! (WorldWind)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆