Weitere ähnliche Inhalte
Mehr von Takahiro Sugiura (10)
Kürzlich hochgeladen (11)
もしトラ
- 1. もしトラ
2011/05/28
at レッツゴーデベロッパー2011
2011/06/17
at G*ワークショップ
- 52. コード例 : Java
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class Hello extends Application {
@Override
public void start(Stage stage) {
// コンテナ
Group container = new Group();
// シーングラフのルート要素を生成し、コンテナを貼る
Scene scene = new Scene(container, 100, 20);
stage.setScene(scene);
// ラベルを生成しコンテナに貼る
Label label = new Label("Hello, World!");
container.getChildren().add(label);
// 表示
stage.setVisible(true);
}
public static void main(String[] args) {
Application.launch(Hello.class, null);
}
}
- 53. コード例 : Groovy
package demo
import javafx.application.Application
import javafx.scene.Group
import javafx.scene.Scene
import javafx.scene.control.Label
Import javafx.scene.text.Font
import javafx.stage.Stage
class Hello extends Application {
void start(Stage stage) {
// シーングラフのルート要素を生成し、コンテナを貼る
def scene = new Scene(
new Group(
new Label(text: 'Hello, World!', font: new Font(20)),
),
100, 30
)
stage.scene = scene
// 表示
stage.visible = true
}
}
Application.launch(Hello, null)
- 54. コード例 : Groovy+GroovyFX
package demo
import groovyx.javafx.GroovyFX
import groovyx.javafx.SceneGraphBuilder
import javafx.scene.text.Font
GroovyFX.start { primaryStage ->
new SceneGraphBuilder(primaryStage).stage(
title: 'Demo',
width: 100,
height: 60,
visible: true
) {
scene (width: 100, height: 30) {
group {
label(text: 'Hello, World!',
font: new Font(20))
}
}
}
}