@Override
    protected final void onButtonClick(Button button) {
        if (!frozen && button.active && button.visible) {
            switch (button.id) {
                default:
                    this.openTexture(texturePacks.get(button.id + page).location);
                    break;
                case BUTTON_LOAD_FILE:
                    frozen = true;
                    SwingUtilities.invokeLater(new ChooseFileRunnable());
                    break;
                case BUTTON_CANCEL:
                    minecraft.setCurrentScreen(parent);
                    break;
                case BUTTON_DEFAULT:
                    try {
                        LogUtil.logInfo("Resetting texture pack to default.");
                        // Save preference
                        minecraft.settings.lastUsedTexturePack = null;
                        minecraft.settings.save();

                        // Reset the texture pack
                        minecraft.textureManager.useDefaultTextures();
                        minecraft.textureManager.reloadTextures();

                        // Return back to the main menu
                        minecraft.setCurrentScreen(parent);

                    } catch (IOException ex) {
                        // If the default texture could not be loaded, something went seriously wrong
                        LogUtil.logError("Error loading default texture pack.", ex);
                        minecraft.setCurrentScreen(new ErrorScreen("Client error", "The game broke! [" + ex + "]"));
                    }
                    break;
                case BUTTON_PREVIOUS:
                    setOffset(page - PACKS_PER_PAGE);
                    break;
                case BUTTON_NEXT:
                    setOffset(page + PACKS_PER_PAGE);
                    break;
            }
        }
    }