[英]Cannot find symbol even though class (Font) & method (font) are declared?
I'm writing my codes and couldn't compile even though the class (Font) is already imported via import javafx.scene.text.*;
我正在编写代码,即使已经通过
import javafx.scene.text.*;
了类(Font),也无法编译import javafx.scene.text.*;
and I know that method font
is included within Font. 而且我知道
font
中包含方法字体。
Here's my code: 这是我的代码:
package helloworld;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.GridPane;
import javafx.scene.text.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.geometry.*;
import javafx.scene.paint.Color;
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("PDF Export");
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Text scenetitle = new Text("PDF Password");
scenetitle.setFont(Font.font("Tahoma",FontWeight.NORMAL,20));
grid.add(scenetitle, 0, 0, 2, 1);
...
}
And when I compile, here's the error I got 当我编译时,这是我得到的错误
PS D:\Documents\javafx\helloworld> javac HelloWorld.java
HelloWorld.java:58: error: cannot find symbol
scenetitle.setFont(Font.font("Tahoma",FontWeight.NORMAL,20));
^
symbol: method font(String,FontWeight,int)
location: class Font
1 error
Would anyone kindly tell me what I'm missing? 有人可以告诉我我所缺少的吗? Because I can't seem to figure out what I might have done wrong.
因为我似乎无法弄清楚我做错了什么。
I find that a lot with JavaFX I have to clean my project after any changes to the things related to JavaFX. 我发现在使用JavaFX进行很多工作之后,必须对与JavaFX相关的内容进行任何更改后再清理项目。
(I run NetBeans but the error could be in other IDEs as well). (我运行NetBeans,但该错误也可能发生在其他IDE中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.