Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

X3D Edit in Java code

3071418Dec 13 2015 — edited Dec 13 2015

I'm using X3D Edit in Netbeans 8.1 and I'm planning on importing several dozen X3D models in. The application that I'm aiming to make to load different .x3d models when clicked. I'm programming the rest of the application in java, and the code that I have so far is as follows:

import java.awt.Color;

import java.awt.Dimension;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyEvent;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JPanel;

class MenuActionListener implements ActionListener {

     public void actionPerformed(ActionEvent e) {

          System.out.println("Selected: " + e.getActionCommand());

     }

}

public class HeritageTogeter{

     public static void main(final String args[]) {

          JFrame frame = new JFrame("3D Heritage Model Viewer");

          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

          JMenuBar menuBar = new JMenuBar();

         

          //File Menu, F -Mnemonic

          JMenu fileMenu = new JMenu("Areas");

          fileMenu.setMnemonic(KeyEvent.VK_F);

          menuBar.add(fileMenu);

          //File->New, N - Mnemonic

          JMenuItem new MenuItem = new JMenuItem("Area1");

          newMenuItem.addActionListener(new MenuActionListener());

          fileMenu.add(newMenuItem);

          JMenuItem new MenuItem = new JMenuItem("Area2");

          newMenuItem.addActionListener(new MenuActionListener());

          fileMenu.add(newMenuItem);

          JMenu fileMenu = new JMenu("Types of Models");

          fileMenu.setMnemonic(KeyEvent.VK_F);

          menuBar.add(fileMenu);

          JMenuItem new MenuItem = new JMenuItem("Model1");

          newMenuItem.addActionListener(new MenuActionListener());

          fileMenu.add(newMenuItem);

          JMenuItem new MenuItem = new JMenuItem("Model2");

          newMenuItem.addActionListener(new MenuActionListener());

          fileMenu.add(newMenuItem);

          frame.setJMenuBar(menuBar);

          frame.setSize(1200, 650);

          frame.setVisible(true);

          //Set up first subpanel

          JPanel subPanel1 = new JPanel();

          subPanel1.setPreferredSize (new Dimension(600, 650));

          subPanel1.setBackground (Color.white);

          JLabel label1 = new JLabel ("Model One");

          subPanel1.add (label1);

          //Set up second subpanel

          JPanel subPanel2 = new JPanel();

          subPanel2.setPreferredSize (new Dimension(600, 650));

          subPanel2.setBackground (Color.white);

          JLabel label2 = new JLabel ("Model Two");

          subPanel2.add (label2);

          //Set up primary panel

          JPanel primary = new JPanel();

          primart.setBackground (Color.black);

          primary.add (subPanel1);

          primary.add (subPanel2);

          frame.getContentPane().add(primary);

          frame.pack();

          frame.setVisible(true);

     }

}

What I want to know is, is if there is a line or two of java code that will help import the .x3d models that I have saved on my USB into the application.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 10 2016
Added on Dec 13 2015
0 comments
1,001 views