Autocompletion window (Fx & Swing)
When I try to display the autocompletion window it goes back of my FX window, I tried everything but with no result !
Thanks in advance
I haven't done too much with JavaFX, though I recall it being kind of buggy when I tried to embed Swing components into a JavaFX app (a very long time ago).
Can you provide an SSCCE that demonstrates this behavior?
Here is the SSCCE, all you need is importing the Auto-completion jar file and you ready to go :
public class Main extends Application {
private RSyntaxTextArea editorZone;
private JPanel panelSwing = new JPanel(new BorderLayout());
@Override
public void start(Stage primaryStage){
final SwingNode swingNode = new SwingNode();
SwingUtilities.invokeLater(() -> initSwing(swingNode));
BorderPane root = new BorderPane();
root.setCenter(swingNode);
Scene scene = new Scene(root, 600, 575);
primaryStage.setScene(scene);
primaryStage.show();
}
private void initSwing(SwingNode swingNode) {
swingNode.setContent(panelSwing);
editorZone = new RSyntaxTextArea(20, 60);
CompletionProvider provider = createCompletionProvider();
AutoCompletion ac = new AutoCompletion(provider);
ac.install(editorZone);
ac.setShowDescWindow(true);
ac.setAutoCompleteEnabled(true);
ac.setAutoActivationEnabled(true);
ac.setAutoCompleteSingleChoices(false);
ac.setAutoActivationDelay(0);
RTextScrollPane editor = new RTextScrollPane(editorZone);
panelSwing.add(editor);
}
private CompletionProvider createCompletionProvider() {
DefaultCompletionProvider provider = new DefaultCompletionProvider();
provider.setAutoActivationRules(true, null);
provider.addCompletion(new ShorthandCompletion(provider, "sysout","System.out.println(", "System.out.println("));
provider.addCompletion(new ShorthandCompletion(provider, "syserr", "System.err.println(", "System.err.println("));
return provider;
}
public static void main(String[] args) {
launch(args);
}
}
Hi, I know that this is an old discussion, but do you finally solved the back window problem? I'm still to try place RSyntaxTextArea on JFX form and starting from your code here I don't want have the same problem you had.
Many thanks