entry.removeTileChange(num); updateComponents(false, true, false); } else JOptionPane.showMessageDialog(mainWindow, "ERROR: No change with number " + (num + 1) + "!", "Error deleting!", JOptionPane.ERROR_MESSAGE);
while (entry.size() > 0) entry.removeTileChange(0); updateComponents(false, true, false); } else if (!input.toLowerCase().equals("none")) JOptionPane.showMessageDialog(mainWindow, "ERROR: \"" + input + "\" is not a valid number.", "Error deleting!", JOptionPane.ERROR_MESSAGE); }
	public void actionPerformed(ActionEvent e)	{		if (e.getActionCommand().equals("apply"))        {            int status = saveInfo();            if (status < 1)            	JOptionPane.showMessageDialog(mainWindow,            		    "ERROR: " + errorMessages[status * -1],            		    "Error saving changes!",            		    JOptionPane.ERROR_MESSAGE);            else if (! writeToRom(this))            	JOptionPane.showMessageDialog(mainWindow,            		    "ERROR: Not enough space for changes, so remove some!",            		    "Error writing!",            		    JOptionPane.ERROR_MESSAGE);        }        else if (e.getActionCommand().equals("close"))        	hide();        else if (e.getSource().equals(addGroup))        {        	TilesetChange change = new TilesetChange((short) 1, false);        	entries[tileset.getSelectedIndex()].add(change);        	updateComponents(true, false, true);        	flagGroup.setSelectedIndex(entries[tileset.getSelectedIndex()].indexOf(change));        }        else if (e.getSource().equals(delGroup))        {        	int confirm = JOptionPane.showConfirmDialog(        		    mainWindow,        		    "Do you really want to delete this flag group?",        		    "Are you sure?",        		    JOptionPane.YES_NO_OPTION);        	if (confirm == JOptionPane.YES_OPTION)        		entries[tileset.getSelectedIndex()].remove(flagGroup.getSelectedIndex());        	updateComponents(true, false, true);        }        else if (e.getSource().equals(tileset))        	updateComponents(true, false, false);        else if (e.getSource().equals(flagGroup))        	updateComponents(false, false, true);        else if (e.getSource().equals(palette))        	updateComponents(false, false, false);        else if (e.getSource().equals(page))        	updateComponents(false, false, false);        else if (e.getSource().equals(add))        {        	((TilesetChange) entries[tileset.getSelectedIndex()].get(        			flagGroup.getSelectedIndex())).addTileChange(new TilesetChange.TileChange((short) 0, (short) 0));        	updateComponents(false, true, false);        }        else if (e.getSource().equals(del))        {        	String input = JOptionPane.showInputDialog(                    mainWindow,                    "Delete which tile change?",                    Integer.toString(1));        	if ((input != null) && (input.length() > 0))        	{        		int num = Integer.parseInt(input) - 1;        		TilesetChange entry = (TilesetChange) entries[tileset.getSelectedIndex()].get(            			flagGroup.getSelectedIndex());        		if ((num >= 0) && (num <= entry.size()))        		{        			if (selected / 2 == num)        				selected = -1;        			entry.removeTileChange(num);        			updateComponents(false, true, false);        		}        		else        			JOptionPane.showMessageDialog(mainWindow,                		    "ERROR: No change with number " + (num + 1) + "!",                		    "Error deleting!",                		    JOptionPane.ERROR_MESSAGE);        	}        }        else if ((e.getSource().equals(tileChooser)) && (selected != -1))        {        	TilesetChange change = ((TilesetChange) entries[tileset.getSelectedIndex()].get(        			flagGroup.getSelectedIndex()));        	if (selected % 2 == 0)    			change.getTileChange(selected / 2).setTile1((short) tileChooser.getSelected());    		else    			change.getTileChange(selected / 2).setTile2((short) tileChooser.getSelected());    		updateComponents(false, false, false);	        }        else if (e.getSource() instanceof TileButton)        {        	selected = Integer.parseInt(e.getActionCommand());        	TilesetChange change = ((TilesetChange) entries[tileset.getSelectedIndex()].get(        			flagGroup.getSelectedIndex()));        	if (selected % 2 == 0)        		tileChooser.setSelected(change.getTileChange(selected / 2).getTile1());        	else        		tileChooser.setSelected(change.getTileChange(selected / 2).getTile2());        	if (! tileChooser.isSelectedVisible())        		tileChooser.scrollToSelected();        	tileChooser.repaint();        }	}