Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shanescarlett/jstick

The simple joystick component for Java Swing
https://github.com/shanescarlett/jstick

java joystick swing

Last synced: 15 days ago
JSON representation

The simple joystick component for Java Swing

Awesome Lists containing this project

README

        

# 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```:
```xml

net.scarlettsystems.java
jstick
0.0.2

```

## Usage
The component may be instantiated by simply calling its constructor:
```java
JStick myJoystick = new JStick();
```
Adding the component to a panel will automatically have the joystick sized to fill its bounds:
```java
JPanel panel = new JPanel();
panel.add(myJoystick);
```
Attach a listener to be fired each time motion is detected on the joystick:
```java
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

* **Shane Scarlett** - *core development* - [Scarlett Systems](https://scarlettsystems.net)

## Acknowledgements
This component was inspired by Sam Arthur Gilliam's Stackoverflow answer [here](https://stackoverflow.com/questions/16439621/java-on-screen-virtual-joystick-control), and contains heavily modified code from said post.

## License

This project is licensed under the Apache 2.0 License.