problem with javaFX canvas
Cinta Damayanti
si.siput.ngantuk at gmail.com
Thu Sep 26 21:20:13 PDT 2013
I add canvas inside Group Node, and then I add two Button to that Group.
Why that button not available continuously?
This is my code:
package test;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class TestCanvasTest extends Application {
static int width = 400 , height = 400;
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
final Canvas canvas = new Canvas(width, height);
final GraphicsContext gc = canvas.getGraphicsContext2D();
Button button1 = new Button();
button1.setText("START");
button1.setMinWidth(100);
button1.setTranslateX(10);
button1.setTranslateY(10);
Button button2 = new Button();
button2.setText("PAUSE");
button2.setMinWidth(100);
button2.setTranslateX(10);
button2.setTranslateY(40);
root.getChildren().add(canvas);
root.getChildren().addAll(button1, button2);
Scene scene = new Scene(root, width, height);
stage.setScene(scene);
gc.setFill(Color.RED);
gc.fillRect(0, 0, width, height);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
and you view the result in youtube:
http://www.youtube.com/watch?v=I-XMcMjKeQk
More information about the openjfx-dev
mailing list