如何将Polyline添加到窗格数组?

时间:2015-04-17 23:17:17

标签: arrays javafx pane

好的,我在这里做什么。我正在尝试制作一个使用20个随机双打数据流的程序,然后使用20个随机doulbe来制作10个不同的折线。
所有这些都需要在单独的stackPanes上。我读数据流很好但是当我尝试将折线添加到StackPanes数组时,我得到一个错误 所以我要问的是你能做到吗?

package project.pkg3;

public class adf extends Application {

@Override
public void start(Stage primaryStage) throws FileNotFoundException {
    Button prevBut = new Button();
    prevBut.setText("Previous");
    Button next = new Button();
    next.setText("Next");
    int scenePane = 0;
    int numOfFiles = 10;
    int numOfDoubles = 20;
    double x = 0;
    double y = 0;
    StackPane[] sPane = new StackPane[numOfFiles];

    HBox hbox = new HBox();
    hbox.setSpacing(10);
    StackPane root = new StackPane();
    hbox.getChildren().add(prevBut);
    hbox.getChildren().add(next);
    hbox.setAlignment(Pos.TOP_CENTER);
    root.getChildren().add(hbox);


    for (int i = 0; i < numOfFiles; i++) {

        try {
            DataInputStream input = new DataInputStream(new FileInputStream("temp" + i + ".dat"));

            Polyline polyline = new Polyline(input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble(), input.readDouble());
            input.close();

            sPane[i].getChildren().add(polyline);
        } catch (EOFException e) {

        } catch (IOException ex) {
            Logger.getLogger(adf.class.getName()).log(Level.SEVERE, null, ex);

        }




    }

0 个答案:

没有答案