Created
July 20, 2017 16:59
-
-
Save Siedlerchr/26e168867b108ccb9ea1152874f3cc91 to your computer and use it in GitHub Desktop.
MWE for Linux bug in javafx/swing accents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package application; | |
import javax.swing.JFrame; | |
import javax.swing.SwingUtilities; | |
import javafx.application.Platform; | |
import javafx.embed.swing.JFXPanel; | |
import javafx.scene.Group; | |
import javafx.scene.Scene; | |
import javafx.scene.control.TextField; | |
import javafx.scene.paint.Color; | |
public class Test { | |
private static void initAndShowGUI() { | |
// This method is invoked on the EDT thread | |
JFrame frame = new JFrame("Swing and JavaFX"); | |
final JFXPanel fxPanel = new JFXPanel(); | |
frame.add(fxPanel); | |
frame.setSize(300, 200); | |
frame.setVisible(true); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
Platform.runLater(new Runnable() { | |
@Override | |
public void run() { | |
initFX(fxPanel); | |
} | |
}); | |
} | |
private static void initFX(JFXPanel fxPanel) { | |
// This method is invoked on the JavaFX thread | |
Scene scene = createScene(); | |
fxPanel.setScene(scene); | |
} | |
private static Scene createScene() { | |
Group root = new Group(); | |
Scene scene = new Scene(root, Color.ALICEBLUE); | |
TextField tf = new TextField(); | |
root.getChildren().add(tf); | |
return (scene); | |
} | |
public static void main(String[] args) { | |
SwingUtilities.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
initAndShowGUI(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment