package bluej.utility.javafx;
import java.util.function.BiConsumer;
import javafx.embed.swing.SwingNode;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.scene.input.KeyEvent;
import threadchecker.OnThread;
import threadchecker.Tag;
| In SwingNode, there is a SwingKeyEventHandler class which translates
| FX keypresses into Swing keypresses. Unfortunately it has a bug,
| wherein AltGr shortcuts on Windows (which are used frequently by
| some non-English users) do not work correctly. This is bug:
|
| Https://bugs.openjdk.java.net/browse/JDK-8088471
|
| And currently has no fix date. Thankfully, a commenter on the bug
| pointed to a solution: overriding the handler to suppress modifiers
| on a particular event. This is implemented by setting a new key handler
| in SwingNode; this class is a simple wrapper which sets the new handler;
| the real fix is in SwingKeyEventHandlerFixed
|
public class SwingNodeFixed
extends SwingNode{
@OnThread(Tag.Any)
public SwingNodeFixed()
{
((BiConsumer<EventType<KeyEvent>, EventHandler<KeyEvent>>)(this::setEventHandler)).accept(javafx.scene.input.KeyEvent.ANY, new SwingKeyEventHandlerFixed(this));
}
}
top,
use,
map,
class SwingNodeFixed
. SwingNodeFixed
27 neLoCode
+ 10 LoComm