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 7956575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:02:17+00:00 2026-06-04T04:02:17+00:00

I started using jMonekyEngine and it’s easy way of interacting with Swing GUI. Following

  • 0

I started using jMonekyEngine and it’s easy way of interacting with Swing GUI.
Following their tutorial here http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:swing_canvas

It all works and I get everything loaded,however I’m having trouble modifying things.

According to their tutorial, the constant update and happens here:

public void simpleUpdate(float tpf) {
    geom.rotate(0, 2 * tpf, 0);
}

(this is an example from the tutorial on rotating objects).
what i’m trying to do is just increasing and decreasing the speed of rotation (by changing the 2 or tpf with a variable which gets update inside an ActionListener in the Swing gui.

However, since in their tutorial they stated that the swing gui is to be created inside the main method, I have to create a variable which is static in order to change it.

static float rotate = 0.0f;

it gets modified inside the main method, but when trying to use it like so:

public void simpleUpdate(float tpf) {
    geom.rotate(0, rotate * tpf, 0);
}

it remains constant to the initial value.
I tried creating a GUI class to build the gui (extends JPanel) and using getters and setters, but still not go..
Any help would be appreciated!
Thanks!

EDIT:
Here’s how I change the rotate value:

JButton faster = new JButton("Faster");
faster.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        rotate +=0.1f;
    }
});

inside the main method. rotate is a static field.

  • 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-06-04T04:02:18+00:00Added an answer on June 4, 2026 at 4:02 am

    This is working for me

    http://test.jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_main_event_loop
    http://test.jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_input_system?s%5B%5D=input

    Is your action listener really triggering the event on click? maybe you have a problem there and not in the rotate variable. Note that I’m not using swing on this example..

    import com.jme3.app.SimpleApplication;
    import com.jme3.input.KeyInput;
    import com.jme3.input.controls.ActionListener;
    import com.jme3.input.controls.KeyTrigger;
    import com.jme3.material.Material;
    import com.jme3.math.ColorRGBA;
    import com.jme3.math.Vector3f;
    import com.jme3.scene.Geometry;
    import com.jme3.scene.shape.Box;
    
    /** Sample 4 - how to trigger repeating actions from the main update loop.
     * In this example, we make the player character rotate. */
    public class HelloLoop extends SimpleApplication {
    
        public static void main(String[] args){
            HelloLoop app = new HelloLoop();
            app.start();
        }
    
        protected Geometry player;
    
        @Override
        public void simpleInitApp() {
    
            Box b = new Box(Vector3f.ZERO, 1, 1, 1);
            player = new Geometry("blue cube", b);
            Material mat = new Material(assetManager,
              "Common/MatDefs/Misc/Unshaded.j3md");
            mat.setColor("Color", ColorRGBA.Blue);
            player.setMaterial(mat);
            rootNode.attachChild(player);
    
            initKeys();
        }
    
        /* This is the update loop */
        @Override
        public void simpleUpdate(float tpf) {
            // make the player rotate
            player.rotate(0, val*tpf, 0); 
        }
        float val = 2f;
        private void initKeys() {
            // Adds the "u" key to the command "coordsUp"
            inputManager.addMapping("sum",  new KeyTrigger(KeyInput.KEY_ADD));
            inputManager.addMapping("rest",  new KeyTrigger(KeyInput.KEY_SUBTRACT));
    
            inputManager.addListener(al, new String[]{"sum", "rest"});
        }
          private ActionListener al = new ActionListener() {
            public void onAction(String name, boolean keyPressed, float tpf) {
              if (name.equals("sum") ) {
                  val++;
              }else if (name.equals("rest")){
                  val--;
              }
            }
          };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started using ModX yesterday. Prepared my multilingual website using this tutorial: http://www.multilingual-modx.com/blog/2011/multilingual-websites-with-modx-and-babel.html .
Started using thinking sphinx today and I'd like to know what's going wrong here:
I started using groups in Xcode the same way I use packages in Java
I started using Chop Slider, an amazing slideshow jquery plugin ( http://www.idangero.us/cs/ ) but
Just started using Apache Commons StringEscapeUtils . According to http://www.w3schools.com/tags/ref_entities.asp , Ö should correspond
i started using oauth2 gem by intridea ( http://github.com/intridea/oauth2 ) and don't know how
I started using NoSQL with Ruby. Here's the code I have require 'mongo' require
I started using a diagnostic css stylesheet, e.g. http://snipplr.com/view/6770/css-diagnostics--highlight-deprecated-html-with-css--more/ One of the suggested rules
Started using Quartz.net in my project. But got stuck. Using cron trigger fires only
Just started using Sencha Touch 2 and need to integrate the Leaflet plugin https://github.com/VinylFox/Ext.ux.touch.Leaflet/tree/master/src

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.