Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数字轴未正确显示javafx_Java_Charts_Javafx - Fatal编程技术网

数字轴未正确显示javafx

数字轴未正确显示javafx,java,charts,javafx,Java,Charts,Javafx,出于某些原因,我想在javafx应用程序中创建一个单独的数字轴(没有任何图表)。我的问题是,轴似乎根本没有扩展,因此从轴上看不到任何值 下面是我的问题的一个例子: package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.chart.NumberAxis; import javafx.s

出于某些原因,我想在javafx应用程序中创建一个单独的数字轴(没有任何图表)。我的问题是,轴似乎根本没有扩展,因此从轴上看不到任何值

下面是我的问题的一个例子:

package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.chart.NumberAxis;
import javafx.scene.layout.BorderPane;
public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            BorderPane root = new BorderPane();
            NumberAxis axis = new NumberAxis(0, 100, 1);
            axis.setMinWidth(300);
            axis.setPrefWidth(300);
            axis.setMaxWidth(300);
            axis.setLabel("testAxis");
            root.getChildren().add(axis);

            Scene scene = new Scene(root,400,400);

            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

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

有人能帮我吗?

我想没有图表的轴是行不通的。当你用一条线和刻度画出你自己的轴时怎么样

    Pane root = new Pane();

    Scene scene = new Scene(root, 300, 250);

    Line lineScal = new Line(0, 50, 600, 50);
    lineScal.setStroke(Color.LIGHTBLUE);
    for (int i = 600; i >= 0; i = i - 50)

    {

        Line line1 = new Line(i, 50, i, 30);

        Text scaleText = new Text(i, 20, Double.toString(i));
        line1.setStroke(Color.LIGHTGRAY);

        root.getChildren().addAll(line1,scaleText);

    }

    root.getChildren().add(lineScal);
    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args)
{
    launch(args);
}

我假设没有图表的轴不起作用。当你用一条线和刻度画出你自己的轴时怎么样

    Pane root = new Pane();

    Scene scene = new Scene(root, 300, 250);

    Line lineScal = new Line(0, 50, 600, 50);
    lineScal.setStroke(Color.LIGHTBLUE);
    for (int i = 600; i >= 0; i = i - 50)

    {

        Line line1 = new Line(i, 50, i, 30);

        Text scaleText = new Text(i, 20, Double.toString(i));
        line1.setStroke(Color.LIGHTGRAY);

        root.getChildren().addAll(line1,scaleText);

    }

    root.getChildren().add(lineScal);
    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args)
{
    launch(args);
}

我想了想,但是我怎么能轻易地把我的分数放在上面呢?看看我编辑过的答案,如果有帮助的话,按答案打分:)我想了想,但是我怎么能轻易地把我的分数放在上面呢?看看我编辑过的答案,如果有帮助的话,按答案打分:)