【发布时间】:2018-10-05 09:18:16
【问题描述】:
我有一个密码。它有错误,我想知道如何修复错误。错误对应这一行:public void start(Stage primaryStage)
代码如下:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class DescriptionPane extends BorderPane{
/** Label for displaying an image and a title */
private Label lblImageTitle = new Label();
/** Text area for displaying text */
private TextArea taDescription = new TextArea();
public DescriptionPane() {
// Center the icon and text and place the text under the icon
lblImageTitle.setContentDisplay(ContentDisplay.TOP);
lblImageTitle.setPrefSize(200, 100);
// Set the font in the label and the text field
lblImageTitle.setFont(new Font("SansSerif", 16));
taDescription.setFont(new Font("Serif", 14));
taDescription.setWrapText(true);
taDescription.setEditable(false);
// Create a scroll pane to hold the text area
ScrollPane scrollPane = new ScrollPane(taDescription);
// Place label and scroll pane in the border pane
setLeft(lblImageTitle);
setCenter(scrollPane);
setPadding(new Insets(5, 5, 5, 5));
}
/** Set the title */
public void setTitle(String title) {
lblImageTitle.setText(title);
}
/** Set the image view */
public void setImageView(ImageView icon) {
lblImageTitle.setGraphic(icon);
}
/** Set the text description */
public void setDescription(String text ) {
taDescription.setText(text);
}
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(taDescription, 400, 200);
primaryStage.setTitle("RadioButtonDemo");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
我也在此处粘贴错误。错误如下所示。谁能帮我解决这个问题。非常感谢!
线程“main”中的异常 java.lang.RuntimeException:错误:类 DescriptionPane 不是 javafx.application.Application 的子类 在 javafx.graphics/javafx.application.Application.launch(未知来源) 在 DescriptionPane.main(DescriptionPane.java:69)
【问题讨论】:
-
extends Application -
根据报错是这个:
DescriptionPane extends BorderPane{,应该是这个:DescriptionPane extends java.fx.application.Application{...话虽如此,不知道会不会出现新的问题:D -
@npinti,不,不对
-
@achAmháin,不,不对
标签: java