Trouble with Arrays of Menus and Menu Items

Okay the short story is I am designing a GUI for an application, it has a lot of menus, and a lot of menu items per menu.
I thought like in normal Java I could simply make an array of Menus and several arrays of menu items. My problem is that it compiles fine, but spews tons of exceptions. I am using Netbeans as my IDE.
Here is a sample of my code. Its not the whole thing, but its the part that I suspect has problems since it worked before I switched to doing them as arrays.
Menu [] menus = new Menu [11];
menus[0].setText("File");
MenuItem [] file = new MenuItem [8]; //FILE MENU DEFINITIONS
file[2].setText("Open"); //open
file[2].setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
FileChooser fc = new FileChooser();
File file =fc.showOpenDialog(primaryStage);
// file[2].setAccelerator(null);
menus[0].getItems().addAll(file);
MenuBar menubar = MenuBarBuilder.create()
.build();
menubar.getMenus().addAll(menus);
VBox vbox1 = VBoxBuilder.create()
.children(menubar,scrollPane1,btn)
.build();
ap.getChildren().addAll(vbox1);
Anyways the stuff compiles just fine no errors. But Netbeans spews exceptions like a guy who chugged a bottle of ipecac and the programs bombs.
Here is some of them.
Exception in Application start method
java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at com.javafx.main.Main.launchApp(Main.java:642)
     at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Exception in Application start method
     at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
     at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
     at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
     at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
     at javafxapplication2.JavaFXApplication2.start(JavaFXApplication2.java:37)
     at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
     at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
     at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
     at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
     at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
     at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
     ... 1 more
Java Result: 1
I am not really sure what to do. I would like some recommendations.
If possible I would still like to use arrays of Menus and Menu Items, but if its not possible, I would like to know and understand why not.

I apologize if I don't fully understand. I am still kind new to this. But It was my understanding that .jar file was made after compiling not before. I am not really sure what you mean by class path. Could you give an example. Again this code worked wonderfully before I used arrays. If I comment it out and replace it with dummy code like this it compiles and runs just fine.
MenuItem open = new MenuItem("TEST");
Menu debug =new Menu("DEBUG");
debug.getItems().add(open);
MenuBar menubar = MenuBarBuilder.create()
.build();
menubar.getMenus().addAll(debug);
StackPane rootz = new StackPane();
final TextArea textArea =TextAreaBuilder.create()
.prefWidth(600)
.prefHeight(400)
.wrapText(true)
.build();
ScrollPane scrollPane1 = new ScrollPane();
scrollPane1.getStyleClass().add("no-border-scroll-pane");
scrollPane1.setMinSize(400, 400);
scrollPane1.setContent(textArea);
VBox vbox1 = VBoxBuilder.create()
.children(menubar,scrollPane1,btn)
.build();
ap.getChildren().addAll(vbox1);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
System.out.println("Hello World!");
FileChooser fc = new FileChooser();
File file =fc.showOpenDialog(primaryStage);
Scene scene = new Scene(ap, 760, 500);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.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().
* @param args the command line arguments
public static void main(String[] args) {
launch(args);
}

Similar Messages

  • I have trouble with Firefox displaying menus and options correctly, and I keep it up to date. I have to switch to Safari to perform basic activities. What's up?

    I have Firefox 37.0.1 which I just updated on my MacBook Pro running Mac OX 10.7.5. Frequently, on web sites where I'm following directions to sign in or reset a password or do a financial transaction, like a purchase, there are menus missing from my screen. At first I blame the instructions for not being complete or accurate, but lately I've been trying to switch to another browser, like Safari. And when I do the missing menus appear! What's up? Have I missed a setting in Firefox that allows menus to appear?

    Hi LornaLyons, when I open Firefox's Web Console (Developer menu) and reload the page, only 4 files show a 404 status, the rest of the site seems fine. (Screen shot attached)
    I did reload bypassing cached files, which is Ctrl+Shift+r on Windows but probably is Command+Shift+r on Mac. Does that make any difference for you?
    Could you test the site in Firefox's Safe Mode? That's a standard diagnostic tool to deactivate extensions and some advanced features of Firefox. More info: [[Troubleshoot Firefox issues using Safe Mode]].
    ''If Firefox is not running:'' Hold down the option key when starting Firefox.
    ''If Firefox is running:'' You can restart Firefox in Safe Mode using either:
    * "3-bar" menu button > "?" button > Restart with Add-ons Disabled
    * Help menu > Restart with Add-ons Disabled
    and OK the restart.
    ''Both scenarios:'' A small dialog should appear. Click "Start in Safe Mode" (''not'' Refresh).
    Will the site load?

  • Having trouble with pop-up windows and ads for MacKeeper

    I've been having trouble with pop-up windows and ads for MacKeeper and similar "services." Tried to download "MPlayerX" a week ago and it all started then. I thought I deleted the file but I'm still having trouble. I've been digging for solutions on here, but nothing I've found on here has worked yet--the VSearch stuff (I think) isn't on my hard drive. Any advice?

    You installed a variant of the "VSearch" trojan. Remove it as follows.
    This malware has many variants. Anyone else finding this comment should not expect it to be applicable.
    Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.venus.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.venus.daemon.plist
    /Library/LaunchDaemons/com.venus.helper.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/venus
    /System/Library/Frameworks/v.framework
    The problem may have started when you downloaded and ran an application called "MPlayerX." That's the name of a legitimate free movie player, but the name is also used fraudulently to distribute VSearch. If there is an item with that name in the Applications folder, delete it, and if you wish, replace it with the genuine article from mplayerx.org.
    This trojan is often found on illegal websites that traffic in pirated content such as movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Then, still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.

    Hi,
    I have a MBP 13' Late 2011 and Yosemite 10.10.2 (14C1514).
    Until yesterday, I was using Garmin ConnectIQ SDK and all was working fine.
    Yesterday, I've updated my system with latest security updates and Xcode updates too (Version 6.2 (6C131e)).
    Since, I can't launch the ConnectIQ simulator app, I have this message in console :
    8/04/2015 15:19:04,103 mds[38]: There was an error parsing the Info.plist for the bundle at URL Info.plist -- file:///Volumes/Leto/connectiq-sdk-mac-1.1.0_2/ios/ConnectIQ.bundle/
    The data couldn’t be read because it isn’t in the correct format.
    <CFBasicHash 0x7fa64f44e9a0 [0x7fff7dfc7cf0]>{type = immutable dict, count = 2,
    entries =>
      0 : <CFString 0x7fff7df92580 [0x7fff7dfc7cf0]>{contents = "NSDebugDescription"} = <CFString 0x7fa64f44f0a0 [0x7fff7dfc7cf0]>{contents = "Unexpected character b at line 1"}
      1 : <CFString 0x7fff7df9f5e0 [0x7fff7dfc7cf0]>{contents = "kCFPropertyListOldStyleParsingError"} = Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Conversion of string failed.) UserInfo=0x7fa64f44eda0 {NSDebugDescription=Conversion of string failed.}
    I have looked at this file and it looks like a binary plist
    bplist00ß^P^V^A^B^C^D^E^F^G^H
    ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"$%&'()'+,^[\CFBundleNameWDTXcodeYDTSDKName_^P^XNSHumanReadableCopyrightZDTSDKBuild_^P^YCFBundleDevelopmentRegion_^P^OCFBundleVersi    on_^P^SBuildMachineOSBuild^DTPlatformName_^P^SCFBundlePackageType_^P^ZCFBundleShortVersionString_^P^ZCFBundleSupportedPlatforms_^P^]CFBundleInfoDictionaryVersion_^P^RCFBundleE    xecutableZDTCompiler_^P^PMinimumOSVersion_^P^RCFBundleIdentifier^UIDeviceFamily_^P^QDTPlatformVersion\DTXcodeBuild_^P^QCFBundleSignature_^P^ODTPlatformBuildYConnectIQT0611[iph    oneos8.1o^P-^@C^@o^@p^@y^@r^@i^@g^@h^@t^@ ^@©^@ ^@2^@0^@1^@5^@ ^@G^@a^@r^@m^@i^@n^@.^@ ^@A^@l^@l^@ ^@r^@i^@g^@h^@t^@s^@ ^@r^@e^@s^@e^@r^@v^@e^@d^@.V12B411RenQ1V14C109Xiphoneos    TBNDLS1.0¡#XiPhoneOSS6.0YConnectIQ_^P"com.apple.compilers.llvm.clang.1_0S8.1_^P^Tcom.garmin.ConnectIQ¡*^P^AW6A2008aT????^@^H^@7^@D^@L^@V^@q^@|^@<98>^@ª^@À^@Ï^@å^A^B^A^_^A?^AT^    A_^Ar^A<87>^A<96>^Aª^A·^AË^AÝ^Aç^Aì^Aø^BU^B\^B_^Ba^Bh^Bq^Bv^Bz^B|^B<85>^B<89>^B<93>^B¸^B¼^BÓ^BÕ^B×^Bß^@^@^@^@^@^@^B^A^@^@^@^@^@^@^@-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Bä
    I guess it is a normal format but my system seems to be unable to read binary plist ?
    I tried some stuff with plutil
    plutil -lint Info.plist
    Info.plist: Unexpected character b at line 1
    Same for convert
    plutil -convert xml1 Info.plist
    Info.plist: Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
    I also try to download a fresh version of the connectIQ SDK and no changes.
    Any idea ?
    Thanks

    Step by step, how did you arrive at seeing this agreement?

  • I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    Argh - once again, I find my solution right after posting this. Left out one modification to the SWIG script, now it runs in 29 seconds vs C 16 seconds, I can live with that.

  • Trouble with iMovie '11 transitions and themes? I'm running Lion, Mac OS X and just noticed today that the transitions and themes don't seem to be working at all when I start new projects or try to add to old projects.  What is the solve here?

    Trouble with iMovie '11 transitions and themes? I'm running Lion, Mac OS X and just noticed today that the transitions and themes don't seem to be working at all when I start new projects or try to add to old projects.  What is the solve here?
    I've seen notes about clearing the cache but it seems that this is an older OS and I can't find the plist mentioned here because it's an older system.  http://www.youtube.com/watch?v=2cL9RuDV3Qc 
    Thoughts?  Anyone? 

    GUYS, I NEED HELP !
    ANYONE?

  • I had a trouble with my lap top and had to format hard disk and install all soft ware again. could any body tell me how to transfer the application and data in my i phone back to my laptop.

    I had a trouble with my lap top and had to format hard disk and install all soft ware again. could any body tell me how to transfer the application and data in my i phone back to itune.

    You can't. It still thinks that your iPhone is synced with another iTunes library (the one that you had before you reformatted the hard drive.

  • I'm having trouble with my sound up and sound down keys. They're doing other functions. This is only a new thing.

    I'm having trouble with my 'sound up' and 'sound down' keys. They're doing other functions. This is only a relatively new thing.

    You didn't mention what those "other functions" were.  That might help!
    First thing to check is System Preferences > Keyboard > Keyboard tab - make sure "Use all F1, F2, etc. keys as standard function keys" is un-checked.  Hopefully that still works in Mountain Lion.

  • Having trouble with getting on messages and facetime

    having trouble with getting on messages and facetime.  Got two new ipods, one works fine, the other keeps giving us the error: iMessage Activation Could not sign in.  Please check your network connection and try again.  We have tried to reset the factory settings, and verified that the internet is working.  Please help!

    FaceTime, Game Center, Messages: Troubleshooting sign in issues

  • I want to implement three level Horizental navigation on the top navigation and menu items are created based on the data available in a SharePoint List.

    Hi All,
    I want to implement three level Horizental navigation on the top navigation and menu items are created based on the data available in a SharePoint List.
    Implement this requirement through customization, how can i start any help
    Thanks

    Hello,
    You can follow these links to get the result that you want. You can get the desired result either using the custom list or a site map. Please make sure when you edit the master page, dont work on the original v4.master. Always make a a copy and then work
    on it.
    This link will show you how get that navigation using a list.
    http://www.bitsofsharepoint.com/BlogPoint/Lists/Posts/Post.aspx?ID=60
    This link will show you how get that navigation using a sitemap.
    http://www.sharepointdiary.com/2012/01/custom-top-navigation-using-sitemap.html
    Please mark as "Answered" if this helped you.
    Thanks,
    norasampang

  • HT4623 Anyone having trouble with App Store install and cloud store buttons not working after 6.1 update?

    Anyone having trouble with App Store install and cloud store buttons not working after 6.1 update? I go to install an app. I hit install and nothing happens. About a minute later it asks me for my password and then it does nothing. The install button goes back to saying install. However the app shows up in my installed list and in cloud but no app installed.

    OK - I found a helpful post - closed app store app and under Settings/General/Date and Time I reset the date and time by switching off "Set Automatically" and then switching it on again. Went back to App Store, launched it and Updatesseems to be working again.
    Go figure? Logical, No!

  • HT5621 I am having trouble with my Apple ID and AppStore Here are the steps I have taken and the results: 1.     Changed my Apple ID with new email address. 2.     Changed my iCloud with above new email address. 3.     NOW - Apple ID appears correct in Ap

    I am having trouble with my Apple ID and AppStore
    Here are the steps I have taken and the results:
    Changed my Apple ID with new email address.
    Changed my iCloud with above new email address.
    NOW - Apple ID appears correct in AppStore Settings, iCloud and AppStore*
    If I scroll to bottom of screen in *App Store/Featured, I can see that the Apple ID is my new email.
    Upon “updating” Apple ID reflects OLD email.
    Deleted accounts, re-added accounts.
    Signed out and signed in with new UN/Email
    Issue remains the same.

    To migrate your data to a new iCloud account go to Settings>iCloud and turn off all synced data (contacts, calendars, etc.), when prompted choose to keep the data on your phone.  After everything is set to off, scroll to the bottom and tap Delete Account.  Next, create the new iCloud account on your phone and turn on syncing for contacts, calendars, etc again.  If prompted, choose Merge.  This will upload your data to the new iCloud account.

  • Having trouble navigating away from a page with streaming video or using menu items-extremly slow to react

    I watch twit.tv daily. anytime I am on the twit page and try to open another tab or try to use a menu item it takes an extremly long time to react to mouse click. At least 15 to 30 seconds. This started happening several updates ago for version 3.6.

    So, since I got no reply to my question I took the iPod into the Apple store and tried to dock it to another third party device. Same problem, no digital control of the iPod. After about 30 minutes of looking it over, the Apple Genius agreed the issue was likely hardware related and issued me a replacement. So apart from about an hour of my time in the store and however long it will take me to reload my library, I'm rather pleased.

  • Using photoshop elements 9 on a lenovo yoga 2 with retina display is impossible - too small icons and menu items

    can you help me?
    greetings
    werner

    I can completely understand this guy's frustration with the clickpad, it is completely unusuable with the default settings. I played around with the synaptics settings and it is much better now, I just adjusted the FingerHigh and FingerLow options:
    synclient FingerHigh=46
    synclient FingerLow=46
    With these settings, the cursor doesn't twitch around anymore when you try to click something.

  • Trouble with array to spreadsheet string

    I am having trouble with the array to spreadsheet string.
    I have a 1-d array of string, the output spreadsheet string never puts a space on the first row, but all others.
    example:
    05:59:29.170    00000101     8        00 00 07 00 0B 0E 0D 0C
     05:59:29.198    00000100     8        00 00 3A 3A 39 39 39 39
     05:59:29.220    00000101     8        00 00 07 00 0B 0E 0D 0C
     05:59:29.248    00000100     8        00 00 39 39 39 39 39 39
    format string is %s and default tab is delimiter.
    this is screwing up my program because of the "scan for string" function can't be used correctly if the spreadsheet string isnt consistent.
    Any suggestions?
    Thanks

    You don't need to use "array to spreadheet string": You could use plain formatting for full control over the output.
    Still, your observation is a bit odd. Could you attach a simple VI that shows the behavior? (Put your input array into a diagram constant).
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for