if (romType.trim().length() == 0) { JOptionPane.showMessageDialog(mainWindow, "The ROM type may not be an empty string.", "Invalid ROM Type", JOptionPane.ERROR_MESSAGE); return; }
    public void actionPerformed(ActionEvent ae)    {        //stuff that can be done while ROM is loading        if (ae.getActionCommand().equalsIgnoreCase("about"))        {            JOptionPane.showMessageDialog(null, this.createScollingLabel(this                .getFullCredits()), "About" + MainGUI.getDescription() + " "                + MainGUI.getVersion(), JOptionPane.INFORMATION_MESSAGE);        }        else if (ae.getActionCommand().equalsIgnoreCase("consoleDialog"))        {            if (!JHack.isUseConsole())                JHack.out.setEnabled(this.getPrefs().getValueAsBoolean(                    "consoleDialog"));        }        else if (ae.getActionCommand().equalsIgnoreCase("noErrorDialog"))        {        	if (!JHack.isUseConsole())        		JHack.err.setEnabled(! this.getPrefs().getValueAsBoolean(        				"noErrorDialog"));        }        else if (ae.getActionCommand().startsWith("LAF_"))        {            String laf = ae.getActionCommand().substring(4);            prefs.setValue("laf", laf);            try            {                if (!UIManager.getLookAndFeel().getClass().getName()                    .equals(laf))                {                    UIManager.setLookAndFeel(laf);                    SwingUtilities.updateComponentTreeUI(SwingUtilities                        .getRoot(mainWindow));                    JHack.out.updateUI();                    JHack.err.updateUI();                    for (Iterator i = moduleList.iterator(); i.hasNext();)                        ((HackModule) i.next()).updateUI();                }            }            catch (ClassNotFoundException e)            {                e.printStackTrace();            }            catch (InstantiationException e)            {                e.printStackTrace();            }            catch (IllegalAccessException e)            {                e.printStackTrace();            }            catch (UnsupportedLookAndFeelException e)            {                e.printStackTrace();            }        }        else if (ae.getActionCommand().startsWith("comptype_"))        {            String type = ae.getActionCommand().substring(9);            prefs.setValue("updateFormat", type);        }        else        {            //if ROM is still loading, stop            if (isLoading())            {                JOptionPane.showMessageDialog(mainWindow,                    "Please wait for the ROM to load.", "Loading ROM",                    JOptionPane.INFORMATION_MESSAGE);                return;            }            //stuff that should not be done _during_ loading            if (ae.getActionCommand().equalsIgnoreCase("load"))            {                loadRom(null);            }            else if (ae.getActionCommand().equalsIgnoreCase("save"))            {                if (rom.isLoaded)                {                    rom.saveRom();                    doBackup();                }            }            else if (ae.getActionCommand().equalsIgnoreCase("saveAs"))            {                if (rom.isLoaded)                {                    rom.saveRomAs();                    updateTitle();                    //ROM file name changed, add to recent list                    addRecentLoad(rom.getPath());                    refreshRecentLoads();                    doBackup();                }            }            else if (ae.getActionCommand().equalsIgnoreCase("closeRom"))            {                if (rom.isLoaded)                    closeRom();            }            else if (ae.getActionCommand().startsWith("revert-"))            {                this.restoreFromBackup(ae.getActionCommand().substring(7));            }            else if (ae.getActionCommand().startsWith("recentLoad"))            {                loadRom(new File(recentLoadsItems[Integer.parseInt(ae                    .getActionCommand().substring(10))].getText().substring(2)));            }            else if (ae.getActionCommand().equalsIgnoreCase("exit"))            {                this.exit();            }            else if (ae.getActionCommand().equalsIgnoreCase("directio"))            {                //            this.getPrefs().setValueAsBoolean(                //                "useDirectFileIO",                //                !rom.isDirectFileIO());                if (rom.isLoaded && !rom.isDirectFileIO())                {                    int ques = JOptionPane.showConfirmDialog(null,                        "Do you want to save your changes?", "Save?",                        JOptionPane.YES_NO_CANCEL_OPTION);                    if (ques == JOptionPane.CANCEL_OPTION)                    {                        return;                    }                    else if (ques == JOptionPane.YES_OPTION)                    {                        rom.saveRom();                    }                }                File rompath = null;                if (rom.isLoaded)                    rompath = rom.getFilePath();                if (rom instanceof RomMem)                {                    rom = new RomFileIO();                }                else                {                    rom = new RomMem();                }                //            HackModule.rom = rom;                if (rompath != null)                    rom.loadRom(rompath);                for (int i = 0; i < getModuleCount(); i++)                {                    try                    {                        getModuleAt(i).rom = rom;                        getModuleAt(i).hide();                        getModuleAt(i).reset();                    }                    catch (NullPointerException npe)                    {                        //If not module inited yet                    }                }                System.gc();                //System.out.println("Debug: rom classname: " +                // rom.getClass().getName());            }            else if (ae.getActionCommand().equals("selectDefROM"))            {                String romType;                if (rom.isLoaded)                {                    romType = rom.getRomType();                }                else                {                    //JDialog typeDia = new JDialog(mainWindow, "Select or                    // Enter                    // ROM Type", true);                    //typeDia.getContentPane().setLayout(new BorderLayout());                    JComboBox typeSel = new JComboBox(RomTypeFinder                        .getRomTypeNames());                    typeSel.setEditable(true);                    typeSel.setSelectedIndex(0);                    //typeDia.add(typeSel, BorderLayout.NORTH);                    if (JOptionPane.showConfirmDialog(mainWindow, typeSel,                        "Select or Enter ROM Type",                        JOptionPane.OK_CANCEL_OPTION,                        JOptionPane.QUESTION_MESSAGE) != JOptionPane.OK_OPTION)                        return;                    romType = typeSel.getSelectedItem().toString();                }                getPrefs().removeValue(romType + ".orgRomPath");                getPrefs().removeValue(romType + ".expRomPath");                requestOrgRomFile(romType);            }            else if (ae.getActionCommand().startsWith("module"))            {                if (rom.isLoaded)                {                    getModuleAt(                        Integer.parseInt(ae.getActionCommand().substring(6)))                        .show();                }                else                {                    JOptionPane.showMessageDialog(null,                        "You must load a ROM first!", "Error!",                        JOptionPane.ERROR_MESSAGE);                }            }        }    }