所以我似乎无法找到关于为什么 eclipse 无法识别“setPromptText”函数的任何信息。它问我是否要创建方法 setPromptText:import javafx.application.*;import javafx.scene.*;import javafx.stage.*;import javafx.scene.layout.*;import javafx.scene.control.*;import javafx.event.*;import javafx.geometry.*;public class TextField extends Application { TextField tf; Label response; public static void main(String [] args) { launch(args); } public void start(Stage myStage) { myStage.setTitle("Demonstrate a textfield"); FlowPane rootNode = new FlowPane(10,10); rootNode.setAlignment(Pos.CENTER); Scene myScene = new Scene(rootNode, 230, 140); myStage.setScene(myScene); response = new Label("Enter Name: "); Button btnGetText = new Button("Get Name"); tf = new TextField(); tf.setPromptText("Enter a name."); }}
2 回答
暮色呼如
TA贡献1853条经验 获得超9个赞
您需要更改班级的名称,
或者您可以在new Textfield()
声明中指定包。
EG 将相关行更改为:
tf = new javafx.scene.control.TextField();
添加回答
举报
0/150
提交
取消