Skip to content

shanescarlett/JStick

Repository files navigation

JStick

JStick, the simple joystick for Java Swing.

Getting Started

Prerequisites

JStick is compatible with Java language level 8 or newer.

Installation

Add JStick to your Maven project by adding the following dependency to pom.xml:

<dependency>
    <groupId>net.scarlettsystems.java</groupId>
    <artifactId>jstick</artifactId>
    <version>0.0.2</version>
</dependency>

Usage

The component may be instantiated by simply calling its constructor:

JStick myJoystick = new JStick();

Adding the component to a panel will automatically have the joystick sized to fill its bounds:

JPanel panel = new JPanel();
panel.add(myJoystick);

Attach a listener to be fired each time motion is detected on the joystick:

myJoystick.addJoystickListener(new JStick.JoystickListener()
{
    @Override
    public void onJoystickMoved(JStick j)
    {
        int x = j.getStickX();
        int y = j.getStickY();
        //Do something useful
    }

    @Override
    public void onJoystickClicked(JStick j)
    {

    }
});

There are several other configurable parameters including the colour and dead-zone. See the docs for more information.

Version

The most current stable version is 0.0.2

Authors

Acknowledgements

This component was inspired by Sam Arthur Gilliam's Stackoverflow answer here, and contains heavily modified code from said post.

License

This project is licensed under the Apache 2.0 License.

About

The simple joystick component for Java Swing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages