jMonkeyEngine-Contributions / Lemur

Lemur is a jMonkeyEngine-based UI toolkit.
http://jmonkeyengine-contributions.github.io/Lemur/
BSD 3-Clause "New" or "Revised" License
116 stars 33 forks source link

Button addClickCommands need to have @SuppressWarnings("unchecked") #89

Open DanielMartensson opened 4 years ago

DanielMartensson commented 4 years ago

Hi!

Adding a click command to a button, requires a suppress warning.

Example:

@SuppressWarnings("unchecked")
    public void connectToButtonEnableDisableGeometry(Geometry geom) {
        enable3D.addClickCommands(e -> {
            if(enable3D.isPressed() == true && enable3D.getText().contains("Disable") == true) {
                geom.setCullHint(CullHint.Always); // Hide
                enable3D.setText("Enable");
            }else {
                geom.setCullHint(CullHint.Never); // Show
                enable3D.setText("Disable");
            }
        });
    }

Else getters and setters will have problems of the button is a field.

pspeed42 commented 4 years ago

I think the only way around this is to create duplicate versions of all of the var-arg methods that take just a single argument. It's an ugly and unfortunate limitation in Java generics that it can't handle arrays properly.