2014-05-21 2 views
0

fxml에 하드 코딩 된 일부 정적 애니메이션 (즉, 말하자면)이있는 특정 애니메이션을 수행하는 FXML 파일이 있습니다. 내가 뭘 하려는지 동적으로 이러한 개체가 데이터베이스에서 당기고 이러한 개체 기반 도형 fxml 채울 색 같은 특정 속성을 가진 Java 개체에서 셰이프를 만드는 것입니다,이 작업을 수행하는 방법을 잘 모르겠습니다. 아래는 주요 클래스의 코드입니다. 왜 오류가 발생하는지 알지만 다른 방법은 모릅니다.SceneBuilder 2.0 동적 쉐이프 생성

public class TestConveyorView extends GuiceApplication { 

    @Inject 
    private GuiceFXMLLoader fxmlLoader; 

    public Injector createInjector() { 
     return Guice.createInjector(new AbstractModule() { 
      @Override 
      protected void configure() { 
      } 
     }); 
    } 

public static void main(String[] args) { 
    Application.launch(args); 
} 

@Override 
public void init(List<Module> modules) throws Exception { 
} 

    @Override 
    public void start(Stage stage) throws Exception { 
     //GridPane root = new GridPane(); 
    Parent root = fxmlLoader.load(getClass().getClassLoader().getResource("fxml/TestConveyorView.fxml")).getRoot(); 

    Box box = new Box(1, red); 
    Rectangle rectangle = new Rectangle(50,50,box.getColor()); 
    // Can't seem to add it to the scene, problem occurs here. 
    root.getChildren().add(rectangle); 


    Scene scene = new Scene(root); 

    // BackgroundImage background = new BackgroundImage(null, BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT); 
    stage.setScene(scene); 
    stage.show(); 
    } 



} 
+1

우리가 당신을 도울 수있는 곳에서 작성한 코드가 있습니까? – Perneel

답변

0

좋아, 난 내가 생각 간과

AnchorPane root = ... 

간단한 해결하려면

Parent root = ... 

을 변경하여 문제를 해결.