ああJavaFX - TextAreaを使う 2012/11/30

JavaFXです。

だんだん、さわるのがつらくなってきてたりしています。
JavaFXオンリーで使う予定がないので、どうしてもswing+JavaFXでいきたいのですが、前回から、どうも動きが違うのに悩まされ続けています。

今回は、TextAreaを使ってみます。動作の確認は、windows7のjava7とosxのjava7で行いました。両者ともjavafx2.2.3のはず。

結論からいうと、どうもIMEで入力の際の動作が違うようだが結論となります。

JFXPanelの内の処理で何かかが足りないのかなとも考えつつ.


ためした
JavaFXのみのコードです。

import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.layout.Pane; import javafx.stage.Stage; public class TextArea_JavaFXOnly extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { stage.setTitle("JavaFXのみ"); Pane root = new Pane(); Scene scene = new Scene(root, 500, 500); TextArea textArea = new TextArea(); root.getChildren().add(textArea); stage.setScene(scene); stage.show(); } }


つぎにswing+javaFXです。

import java.awt.BorderLayout; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.paint.Color; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class TextArea_swingAndJavaFX { private static void initAndShowGUI() { JFrame frame = new JFrame("Swing and JavaFX"); final JFXPanel fxPanel = new JFXPanel(); frame.setLayout(new BorderLayout()); frame.getContentPane().add(fxPanel, BorderLayout.CENTER); frame.setSize(500, 500); 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) { Scene scene = createScene(); fxPanel.setScene(scene); } private static Scene createScene() { Group root = new Group(); Scene scene = new Scene(root, Color.ALICEBLUE); TextArea textArea = new TextArea(); root.getChildren().add(textArea); return (scene); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initAndShowGUI(); } }); } }

: