jMonkeyEngine / jMonkeyEngine/sdk
New feature for SDK: AbstractControl + Button
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 348
- Forks
- 104
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 3
Description
I opened this Issue to keep track of forum discussions to add the ability to create in custom AbstractControls, functions that can be executed by button clicks.
https://hub.jmonkeyengine.org/t/new-feature-for-sdk-abstractcontrol-buttonproperty/46927
It requires the creation of a dedicated library, for example jme-sdk-devtools, to be published on the MAVEN repository. In this way, the library can be used by users in their Maven or Gradle projects to add graphical functions to AbstractControls and write their own editors with the SDK.
Here is an example:
- ButtonProperty
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ButtonProperty {
String name() default "";
String tooltip() default "";
}
- MyControl
public class MyControl extends AbstractControl {
@Override
protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
@ButtonProperty(name="Click Me", tooltip="sayHello")
public void sayHello() {
System.out.println("Hello: " + MyControl.class.getSimpleName());
}
}
- UIBuilder
import java.lang.reflect.Method;
import org.apache.commons.lang3.reflect.MethodUtils;
import com.jme3.scene.control.Control;
import javax.swing.*;
...
public static JPanel buildPanel(Control control) {
JPanel container = new JPanel(false);
container.setLayout(new MigLayout("fillx"));
...
List<Method> methods = MethodUtils.getMethodsListWithAnnotation(control.getClass(), ButtonProperty.class);
for (Method method : methods) {
ButtonProperty bp = method.getAnnotation(ButtonProperty.class);
JButton button = new JButton(bp.name());
button.setToolTipText(bp.tooltip());
button.addActionListener(e -> {
try {
method.invoke(control);
} catch (ReflectiveOperationException ex) {
ex.printStackTrace();
}
}));
container.add(new JLabel(""), "align righ");
container.add(button, "wrap, pushx, growx");
}
return container;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked forum discussion and the proposed AbstractControl, ButtonProperty, and UIBuilder examples. Define the scope of the dedicated jme-sdk-devtools library, including its Maven publication and how annotated control methods become buttons in SDK editors. Done means the library and integration behavior are specified well enough to implement and consume from Maven or Gradle projects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100