将 NetBeans IDE 6.7 与 J3D 的 Canvas3D 容器结合使用

发布于 2024-07-25 22:33:05 字数 583 浏览 19 评论 0原文

我一直告诉自己这应该很简单,但我完全迷失了。 首先我要说的是,我是 NetBeans IDE 的新手,并且出于需要而使用它。 我对此还不太了解。

我已经成功地为我的应用程序设计了主窗口。 应用程序的右侧本质上是一个三维空间的大窗口,可以可视化数据集上的某些转换。 我已经搜索了调色板和调色板管理器,甚至尝试从 JAR 手动将 Canvas3D 组件添加到调色板,但我仍然无法获取它。

我真的希望能够将该组件拖放到我的应用程序中,直观上来说,这似乎是可能的。 我使用的是 Mac OS X; 我的“关于 NetBeans”的输出说明了更多信息。

产品版本:NetBeans IDE 6.7(内部版本 200906241340)
Java:1.5.0_19; Java HotSpot(TM) 客户端虚拟机 1.5.0_19-137
系统:Mac OS X 版本10.5.7,运行于i386; 麦克罗曼; en_US (nb)
Userdir:/Users/dremelofdeath/.netbeans/6.7

提前感谢您帮助我 - 我真的很感激。

I keep telling myself that this should be simple, and yet I'm completely lost. Let me start by saying that I'm new to NetBeans IDE, and that I am using it out of necessity. I don't really know much about it yet.

I have successfully designed my main window for my application. The right side of the application is essentially a large window into a three-dimensional space that visualizes certain transforms on data sets. I have searched through the palette and the palette manager and even tried to add the Canvas3D component to the palette manually from a JAR, but I still can't get it.

I would really like to be able to drag and drop this component into my application, and intuitively, it seems possible. I'm on Mac OS X; the output from my About NetBeans tells more.

Product Version: NetBeans IDE 6.7 (Build 200906241340)
Java: 1.5.0_19; Java HotSpot(TM) Client VM 1.5.0_19-137
System: Mac OS X version 10.5.7 running on i386; MacRoman; en_US (nb)
Userdir: /Users/dremelofdeath/.netbeans/6.7

Thanks in advance for helping me out -- I really appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪操控生活 2024-08-01 22:33:05

Canvas3D 是一个重量级组件,这意味着它使用本机对等组件来连接 DirectX 或 OpenGL,因此这种组件可能无法用于拖放。 尽管您可以尝试扩展 JPanel。

您可以使用 BoderLayout 非常轻松地手动设置布局。

MyFrame extends JFrame {

etc...

 Container container = getContentPane();
 container.setName("main.container");
 container.setLayout(new BorderLayout());

 container.add(new MyCanvasPanel(), BorderLayout.CENTER);

}  

// this could probably be added to the palete
public class MyCanvasPanel extends JPanel {

    SimpleUniverse su;
    Canvas3D canvas3D;

  public MyCanvasPanel() {
        canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
        add("Center", canvas3D);
        su = new SimpleUniverse(canvas3D);
  }

}

The Canvas3D is a heavyweight component meaning it uses a native peer component to hook into DirectX or OpenGL so probably this kind of component is not available for drag and drop. Though you could try extending a JPanel.

You can setup the layout manually quite easily using a BoderLayout.

MyFrame extends JFrame {

etc...

 Container container = getContentPane();
 container.setName("main.container");
 container.setLayout(new BorderLayout());

 container.add(new MyCanvasPanel(), BorderLayout.CENTER);

}  

// this could probably be added to the palete
public class MyCanvasPanel extends JPanel {

    SimpleUniverse su;
    Canvas3D canvas3D;

  public MyCanvasPanel() {
        canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
        add("Center", canvas3D);
        su = new SimpleUniverse(canvas3D);
  }

}
怪我入戏太深 2024-08-01 22:33:05

完整的初学者指南:

  1. 将 java.awt.Container 添加到 JFrame。 (选择 Beans\java.awt.Container)。
    将该容器的名称设为canvasContainer。
  2. 向类添加公共变量。 (我假设类名是MyJFrame)

    <块引用>

    公共Canvas3D canvas3D;

  3. 框架类的构造如下:

    <块引用>

    公共 MyJFrame() {
    initComponents();
    }

    编辑如下:

    <块引用>

    公共 MyJFrame() {
    initComponents();
    canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
    canvasContainer.add(canvas3D, "中心");
    canvas3D.setSize(canvasContainer.getWidth(), canvasContainer.getHeight());
    }

  4. 在调整容器大小时向容器添加侦听器:(通常在调整窗口大小时)
    选择容器\Properties\Events\componentResized\canvasContainerComponentResized
    输入以下代码:

    <块引用>

    if (canvas3D!=null)
    canvas3D.setSize(canvasContainer.getWidth(), canvasContainer.getHeight());

Complete beginner guide:

  1. Add a java.awt.Container to the JFrame. (Choose Beans\java.awt.Container).
    Let the name of that container be canvasContainer.
  2. Add a public variable to the class. (I assume the class name is MyJFrame)

    public Canvas3D canvas3D;

  3. The construction of the frame class is as follows:

    public MyJFrame() {
    initComponents();
    }

    Edit it as follows:

    public MyJFrame() {
    initComponents();
    canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
    canvasContainer.add(canvas3D, "Center");
    canvas3D.setSize(canvasContainer.getWidth(), canvasContainer.getHeight());
    }

  4. Add a listener to the Container when it is resized: (Often when the window is resized)
    Choose the container \ Properties \ Events \ componentResized \ canvasContainerComponentResized
    Type the following code:

    if (canvas3D!=null)
    canvas3D.setSize(canvasContainer.getWidth(), canvasContainer.getHeight());

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文