Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6001969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:54:38+00:00 2026-05-23T00:54:38+00:00

I don’t manage to give user mouse interaction to a ColorCube by using a

  • 0

I don’t manage to give user mouse interaction to a ColorCube by using a MouseRotate. However, when i use a KeyNavigatorBehaviour, i can control the cube with keyboard as needed.

Here the code i used to test MouseRotate :

import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.GraphicsConfigTemplate3D;
import javax.media.j3d.TransformGroup;
import javax.swing.JFrame;
import javax.vecmath.Point3d;

import com.sun.j3d.exp.swing.JCanvas3D;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;


public class MovingAroundCube extends JFrame {

    private static final long serialVersionUID = 1L;

    public MovingAroundCube(){
        setTitle("Moving around cube");
        setSize(300,300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        JCanvas3D jCanvas3D = new JCanvas3D(new GraphicsConfigTemplate3D());
        jCanvas3D.setSize(300, 300);
        add(jCanvas3D);
        SimpleUniverse universe = new SimpleUniverse(jCanvas3D.getOffscreenCanvas3D());
        universe.getViewingPlatform().setNominalViewingTransform();
        universe.addBranchGraph(createSceneGraph());
    }

    public BranchGroup createSceneGraph() {
        BranchGroup objRoot = new BranchGroup();

        TransformGroup listenerGroup = new TransformGroup();
        listenerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        listenerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        objRoot.addChild(listenerGroup);

        //KeyNavigatorBehavior behaviour = new KeyNavigatorBehavior(listenerGroup);
        MouseRotate behaviour = new MouseRotate(listenerGroup);
        behaviour.setSchedulingBounds(new BoundingSphere(new Point3d(), 100));

        listenerGroup.addChild(behaviour);
        listenerGroup.addChild(new ColorCube(0.4));

        return objRoot;
    }

    public static void main(String[] args) {
        new MovingAroundCube().setVisible(true);
    }


}

If I uncomment the line creating the KeyNavigatorBehaviour and comment the line creating the MouseRotate, user interaction this time is possible .

So, why can’t the cube react to the mouse (when i use MouseRotate behaviour instance) ?

Any help will be appreciated.

System : Xubuntu 11.04
Java3D version : 1.5.2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:54:39+00:00Added an answer on May 23, 2026 at 12:54 am

    There are two ways to solve this dilemma:

    • Use this constructor:
    
        MouseRotate behaviour = new MouseRotate(jCanvas3D, listenerGroup);
    

    or

    • Enable mouse events as long as no MouseListeners are added:
    
        import java.awt.AWTEvent;
    
        JCanvas3D jCanvas3D = new JCanvas3D(new GraphicsConfigTemplate3D()) {
            {
                this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | 
                                  AWTEvent.MOUSE_MOTION_EVENT_MASK |
                                  AWTEvent.MOUSE_WHEEL_EVENT_MASK);
            }
        };
    

    Key events are enabled because ‘setFocusable(true)’ is set in JCanvas3D.

    August, InteractiveMesh

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't ask me why but i can't use this method because I need to
Don't be afraid to use any technical jargon or low-level explanations for things, please.
I don't want my user to even try downloading something unless they have Wi-Fi
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't know a whole lot about streams. Why does the first version work using
don't understand: in my controller: @json = User.all.to_gmaps4rails do |user| \Title\: \#{user.email}\ end in
I don't like Jackson. I want to use ajax but with Google Gson. So
Don't know if anyone can help me with this or if it's even possible.
don't know if this is possible.. I'm using sqlite3 schema: CREATE TABLE docs (id
Don't know why I can't reply to people on here with only a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.