weixin_39918128 2020-11-20 18:07
浏览 0

SpreadSheetView default constructor throws exception

Original report by Anonymous.

I wanted to test the default constructor for the SpreadSheetView and it seems to throw an exception, although the Javadoc states that


#!java

public SpreadsheetView()
Creates a default SpreadsheetView control with no content and a Grid set to null.

My code is simple:


#!java

package burdu.burdusheets;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.controlsfx.control.spreadsheet.SpreadsheetView;

public class MainApp extends Application {


    public void start(Stage stage) throws Exception {

        SpreadsheetView spv = new SpreadsheetView();

        stage.setScene(new Scene(spv));
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     *  args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}


#!java

--- exec-maven-plugin:1.2.1:exec (default-cli) @ BurduSheets ---
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
    at com.sun.javafx.application.LauncherImpl$$Lambda$53/589873731.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at org.controlsfx.control.spreadsheet.SpreadsheetView.initRowFix(SpreadsheetView.java:1085)
    at org.controlsfx.control.spreadsheet.SpreadsheetView.setGrid(SpreadsheetView.java:458)
    at org.controlsfx.control.spreadsheet.SpreadsheetView.<init>(SpreadsheetView.java:435)
    at org.controlsfx.control.spreadsheet.SpreadsheetView.<init>(SpreadsheetView.java:332)
    at burdu.burdusheets.MainApp.start(MainApp.java:14)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
    at com.sun.javafx.application.LauncherImpl$$Lambda$56/104131053.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
    at com.sun.javafx.application.PlatformImpl$$Lambda$49/1768305536.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
    at com.sun.javafx.application.PlatformImpl$$Lambda$52/1407021930.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl$$Lambda$50/1146743572.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$45(GtkApplication.java:126)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$42/379110473.run(Unknown Source)
    ... 1 more
Exception running application burdu.burdusheets.MainApp
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 19.808s
Finished at: Sun Sep 07 19:59:14 EEST 2014
Final Memory: 20M/279M
</init></init>

该提问来源于开源项目:controlsfx/controlsfx

  • 写回答

11条回答 默认 最新

  • weixin_39918128 2020-11-20 18:07
    关注

    Original comment by Anonymous.

    Hi Samir,

    Regarding the first part of your post, wouldn't it be better if the developer would make his customizations for his default Sheet in an extended's class default constructor? But they cannot do that now, because super() throws exception. I'm thinking at the scenario in which the developer will create the same type of spreadsheet multiple times. I think that making this customization in the extended class is better than creating a helper class with a getSpreadsheet method.

    I will create another issue as you suggested.

    评论

报告相同问题?