flag.setText(Integer.toHexString(entry.getFlag() & 0xffff)); reverse.setSelected(entry.isFlagReversed());
	private void updateComponents(boolean changingTileset, boolean updatePage, boolean ignorePalette)	{		if (changingTileset)		{			if (! ignorePalette)			{				palette.removeActionListener(this);		        palette.removeAllItems();		        TileEditor.Tileset tset = TileEditor.tilesets[tileset.getSelectedIndex()];		        for (int i = 0; i < tset.getPaletteCount(); i++)		        	palette.addItem(new String(				               tset.getPalette(i).mtileset + "/"				                    + tset.getPalette(i).mpalette));		        palette.addActionListener(this);			}	        			flagGroup.removeActionListener(this);			flagGroup.removeAllItems();			for (int i = 0; i < entries[tileset.getSelectedIndex()].size(); i++)				flagGroup.addItem("Group #" + i);			flagGroup.setEnabled(entries[tileset.getSelectedIndex()].size() > 0);			if (entries[tileset.getSelectedIndex()].size() > 0)				flagGroup.setSelectedIndex(0);			else				flagGroup.setSelectedIndex(-1);			flagGroup.addActionListener(this);		}		add.setEnabled(flagGroup.getSelectedIndex() != -1);		delGroup.setEnabled(flagGroup.getSelectedIndex() != -1);		flag.setEnabled(flagGroup.getSelectedIndex() != -1);		reverse.setEnabled(flagGroup.getSelectedIndex() != -1);		page.setEnabled(flagGroup.getSelectedIndex() != -1);		if (flagGroup.getSelectedIndex() == -1)		{			del.setEnabled(false);			flag.setText("");			reverse.setSelected(false);			page.removeActionListener(this);			page.removeAllItems();			page.addActionListener(this);			tilesPanel.removeAll();			tilesPanel.add(new JLabel("This tileset has no flag groups."));			selected = -1;		}		else		{			TilesetChange entry = (TilesetChange) entries[tileset.getSelectedIndex()].get(					flagGroup.getSelectedIndex());			if (changingTileset)			{				flagGroup.removeActionListener(this);				flagGroup.removeAllItems();				for (int i = 0; i < entries[tileset.getSelectedIndex()].size(); i++)					flagGroup.addItem("Group #" + i);				flagGroup.setSelectedIndex(0);				flagGroup.addActionListener(this);				flag.setText(Integer.toHexString(entry.getFlag() & 0xffff));				reverse.setSelected(entry.isFlagReversed());			}						if (changingTileset || updatePage)			{				int formerPage = page.getSelectedIndex();				page.removeActionListener(this);				page.removeAllItems();				int extra = 0;				if ((entry.size() % Integer.parseInt(limit.getText()) > 0) || (entry.size() == 0))					extra = 1;				if (Integer.parseInt(limit.getText()) > 0)					for (int i = 0; i < (entry.size() / Integer.parseInt(limit.getText())) + extra; i++)						page.addItem("Page " + (i + 1));				for (int i = formerPage; i >= 0; i--)					if (page.getItemAt(i) != null)					{						page.setSelectedIndex(i);						i = -1;					}				page.addActionListener(this);			}						tilesPanel.removeAll();			del.setEnabled(entry.size() > 0);			if (entry.size() > 0)			{				group = new ButtonGroup();				int start = Integer.parseInt(limit.getText()) * page.getSelectedIndex(), end;				if (start + Integer.parseInt(limit.getText()) > entry.size())					end = entry.size();				else					end = start + Integer.parseInt(limit.getText());				if (entry.size() - 1 < selected / 2)					selected = -1;				for (int i = start; i < end; i++)				{					TilesetChange.TileChange change = entry.getTileChange(i);					JPanel row = new JPanel();					row.add(new JLabel("#" + (i + 1) + " Before: "));					TileButton button = new TileButton(change.getTile1(), tileset.getSelectedIndex(), palette.getSelectedIndex());					if (i * 2 == selected)					{						button.setSelected(true);						if (changingTileset)							tileChooser.setSelected(change.getTile1());					}					group.add(button);					button.setActionCommand(Integer.toString(i * 2));					button.addActionListener(this);					row.add(button);					row.add(new JLabel(" After: "));					button = new TileButton(change.getTile2(), tileset.getSelectedIndex(), palette.getSelectedIndex());					if (i * 2 + 1 == selected)					{						button.setSelected(true);						if (changingTileset)							tileChooser.setSelected(change.getTile1());					}					group.add(button);					button.setActionCommand(Integer.toString(i * 2 + 1));					button.addActionListener(this);					row.add(button);					tilesPanel.add(row);				}			}			else				tilesPanel.add(new JLabel("No tile changes."));		}				tileChooser.setTsetPal(tileset.getSelectedIndex(), palette.getSelectedIndex());		tileChooser.repaint();				mainWindow.pack();	}