Hey guys. I'm having trouble understanding the concept of this command. I'm creating a small game. Here's what I need to do.
1) Have a user specify how many players (2-4)
2) Have the user create names, or custom strings, for each player
3) Sort the names in an array
4) Create a dialog box that throws up the names and allows the user to select which will go first. The selection process should be either a JButton or radio button style, and should include the custom name set by the user.
For the record, steps one through three are done. My instructor said that this method would be the best for displaying the information I needed.
For some reason, it keeps getting this error message.
Exception in thread "main" java.lang.NullPointerException
at javax.swing.plaf.basic.BasicOptionPaneUI.addButtonComponents(Unknown Source)
at javax.swing.plaf.basic.BasicOptionPaneUI.createButtonArea(Unknown Source)
at javax.swing.plaf.basic.BasicOptionPaneUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicOptionPaneUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JOptionPane.setUI(Unknown Source)
at javax.swing.JOptionPane.updateUI(Unknown Source)
at javax.swing.JOptionPane.<init>(Unknown Source)
at javax.swing.JOptionPane.showOptionDialog(Unknown Source)
Your best bet would be to initialize the array once you find out how many players there will be. Then you can just use that array in the input dialog. Otherwise, you'll need to create another array once you figure out there's only 2 players or whatever.