Results 1 to 1 of 1
- 12-30-2010, 03:10 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Problem With JInternalFrame loading on JPanel
I just started using JFormDesigner. What i'am building is something to help me use my sprite, item/object config cache for a game. My problem is I keep getting NullPointerException on loading the JInternalFrame of the CacheEdit loading on to the main JPanel.
The error:
How it works is a JFileChooser loads the three files into the editor. Then theres a button for editing/replacing the raw file or a button that opens a window the manually edits a sprite, item or object config, the second one doesn't work yet. When the first one is clicked it loads CacheDialog which is A combo box and you can choose which raw file to edit. But once I click okay and it throws that exception.Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.robb.editor.guis.dialog.CacheDialog$2.actionPerformed(CacheDialog.java:37) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6263) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6028) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) at java.awt.Container.dispatchEventImpl(Container.java:2085) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
In CacheDialog this is what happens when the okay button is pressed.
Heres the editCache methodJava Code:okayButton.setText("Okay"); okayButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Frame.frame.editCache(comboBox1.getSelectedIndex()); dispose(); } });
And this is the important part of what gets called with CacheEdit(index). Cache Edit extends JInternalFrameJava Code:public void editCache(int index) { CacheEdit ce = new CacheEdit(index); mainPanel.add(ce); }
Now I know theres nothing wrong with my getFile method because it works for the game.Java Code:String[] filesData = new String[editingIndice.getNumFiles()]; for (int i = 0; i < editingIndice.getNumFiles(); i++) { filesData[i] = String.valueOf(i); } fileList.setListData(filesData); fileList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (fileList.getSelectedIndex() == -1) { currentFileIDLabel.setText("No file selected"); currentFileSizeLabel.setText(""); replaceFileButton.setEnabled(false); dumpFileButton.setEnabled(false); removeFileButton.setEnabled(false); return; } byte[] data = null; try { data = editingIndice.getFile(fileList.getSelectedIndex()); } catch (IOException e1) { e1.printStackTrace(); } if (data == null) { currentFileIDLabel.setText("File contains no data"); currentFileSizeLabel.setText(""); replaceFileButton.setEnabled(false); dumpFileButton.setEnabled(false); removeFileButton.setEnabled(false); return; } currentFileIDLabel.setText("File ID: " + fileList.getSelectedIndex()); currentFileSizeLabel.setText("Size: " + data.length); } }); scrollPane1.setViewportView(fileList);
Hopefully someone can help.
Similar Threads
-
Problem loading in a .txt file
By blkshp1990 in forum New To JavaReplies: 1Last Post: 11-06-2009, 02:48 AM -
Problem in loading Image
By rahulm87 in forum Java 2DReplies: 1Last Post: 09-08-2009, 04:45 PM -
Problem with JInternalFrame
By hameem in forum AWT / SwingReplies: 1Last Post: 12-11-2008, 04:23 PM -
Problem loading resources.
By jimm1 in forum Advanced JavaReplies: 6Last Post: 06-23-2008, 07:31 PM -
Problems while loading a JPanel to JApplet...
By Ananth Chellathurai in forum Java AppletsReplies: 0Last Post: 11-24-2007, 10:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks