Forum Stats

  • 3,836,734 Users
  • 2,262,175 Discussions
  • 7,900,088 Comments

Discussions

JavaFX2.0 instance of own group

865128
865128 Member Posts: 4
edited May 28, 2011 11:59AM in JavaFX 2.0 and Later
Hi, could anyone tell m where my failure is? I'm playing with the examples from JavaFX...

Heres the GameGroup:
public class GameGroup extends Group{
    
    GameGroup()
    {
        Group circles = new Group();
        for (int i = 0; i < 30; i++) {
            Circle circle = new Circle(150, Color.web("white", 0.05));
            circle.setStrokeType(StrokeType.OUTSIDE);
            circle.setStroke(Color.web("white", 0.16));
            circle.setStrokeWidth(4);
            circles.getChildren().add(circle);
        }
        circles.setEffect(new BoxBlur(10, 10, 3));
    }
}
And this is the part of the Main Class:
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("QQQ");
        Group root = new Group();
        Scene scene = new Scene(root, 800, 600, Color.BLUE);
        GameGroup gameGroup = new GameGroup();
        gameGroup.setTranslateX(50);
        gameGroup.setTranslateY(50);
        root.getChildren().add(gameGroup);        
        primaryStage.setScene(scene);
        primaryStage.setVisible(true);
    }
All I do see is a blue screen...

Edited by: 862125 on 28.05.2011 04:44

Answers

  • shakir.gusaroff
    shakir.gusaroff Member Posts: 689 Gold Badge
    I am not 100% sure. But you can try this:
    import javafx.scene.*;
    import javafx.scene.shape.*;
    import javafx.scene.paint.*;
    import javafx.scene.effect.BoxBlur;
    public class GameGroup  extends Group{
        
        GameGroup()
        {
            //Group circles = new Group();
            for (int i = 0; i < 30; i++) {
                Circle circle = new Circle(150, Color.web("white", 0.05));
                circle.setStrokeType(StrokeType.OUTSIDE);
                circle.setStroke(Color.web("white", 0.16));
                circle.setStrokeWidth(4);
               // circles.getChildren().add(circle);
                getChildren().add(circle);
            }
            
           // circles.setEffect(new BoxBlur(10, 10, 3));
            setEffect(new BoxBlur(10, 10, 3));
        }
    }
    shakir.gusaroff
  • 865128
    865128 Member Posts: 4
    Thank you Shakir, that's it.
This discussion has been closed.