Contenu connexe Plus de Kazuhiro Eguchi (8) JavaFX84. What is JavaFX
• Swingに換わる新しいGUI フレームワーク
• XML(FXML)による画面定義
• CSSによるスタイリング
• アニメーション/エフェクト
• データバインディング
6. TextFlow サンプル
String family = "Helvetica";
double size = 20;
TextFlow textFlow = new TextFlow();
Text text1 = new Text("Hello ");
text1.setFont(Font.font(family, size));
Text text2 = new Text("Bold");
text2.setFont(Font.font(family, FontWeight.BOLD, size));
Text text3 = new Text(" ITALIC");
text3.setFont(Font.font(family, FontPosture.ITALIC, size));
textFlow.getChildren().addAll(text1, text2, text3);
7. TextFlow サンプル
String family = "Helvetica";
double size = 64;
TextFlow textFlow = new TextFlow();
Text text1 = new Text("Hello ");
text1.setFont(Font.font(family, size));
Text text2 = new Text("Bold");
text2.setFont(Font.font(family, FontWeight.BOLD, size));
Text text3 = new Text(" ITALIC");
text3.setFont(Font.font(family, FontPosture.ITALIC, size));
textFlow.getChildren().addAll(text1, text2, text3);
太字
イタリック
9. Textにスタイルを追加
text1.setStyle("-fx-stroke: rgb(255, 0, 0);-fx-fill: rgba(255, 0, 0, 0.2);");
text2.setStyle("-fx-fill: green;-fx-effect: dropshadow(gaussian, gray, 8, 0.5, 8,
8);");
text3.setStyle("-fx-underline: true;-fx-fill: transparent;-fx-stroke: linear-
gradient(from 0% 0% to 100% 100%, repeat, black 0%, blue 50%);-fx-
stroke-width: 1;");
14. Box / Cylinder / Sphere サンプル
Box box = new Box(100, 100, 100);
Cylinder cylinder = new Cylinder(50, 100, 30);
Sphere sphere = new Sphere(50);
16. Material サンプル
Box box = new Box(100, 100, 100);
box.setMaterial(new PhongMaterial(Color.RED));
Cylinder cylinder = new Cylinder(50, 100, 30);
cylinder.setMaterial(new PhongMaterial(Color.YELLOW));
Sphere sphere = new Sphere(50);
sphere.setMaterial(new PhongMaterial(Color.GREEN));
22. Loader Support (OpenJDKWiki)
• Many 3D file formats exist, such as:
• Obj, Maya, 3D Studio Max, Collada, KRML
• We will not provide a loader as part of the JavaFX runtime
• We will make sample code available for one or two popular format