diff --git a/src/main/java/net/minecraftforge/installer/ui/InstallerPanel.java b/src/main/java/net/minecraftforge/installer/ui/InstallerPanel.java index e8ef101..054fce0 100644 --- a/src/main/java/net/minecraftforge/installer/ui/InstallerPanel.java +++ b/src/main/java/net/minecraftforge/installer/ui/InstallerPanel.java @@ -258,7 +258,7 @@ private void updateFilePath() Action action = actions.get(choiceButtonGroup.getSelection().getActionCommand()).apply(null); TargetValidator.ValidationResult valid = action.getTargetValidator().validate(targetDir); - if (profile.getMirror() != null) + if (profile.getMirror() != null && profile.getMirror().isAdvertised()) { sponsorButton.setText(action.getSponsorMessage()); sponsorButton.setToolTipText(profile.getMirror().getHomepage()); @@ -304,22 +304,13 @@ public void run(ProgressCallback monitor) languageBox.setSelectedItem(known.stream().filter(locate -> locate.locale.equals(current)).findFirst().orElse(known.get(0))); languageBox.addActionListener(e -> TRANSLATIONS.setLocale(((L10nManager.LocaleSelection)languageBox.getSelectedItem()).locale, true)); - JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, new Object[] { - TRANSLATIONS.button("installer.button.proceed"), TRANSLATIONS.button("installer.button.cancel"), languageBox - }); - - // Attempt to change the OK button to a Proceed button - // Use index 1 (the buttons panel) as 0 is this panel - final JPanel buttonPanel = (JPanel) optionPane.getComponents()[1]; - final List buttons = Arrays.stream(buttonPanel.getComponents()) - .filter(comp -> comp instanceof JButton) - .map(JButton.class::cast) - .collect(Collectors.toList()); - if (buttons.size() == 2) { - proceedButton = Optional.of(buttons.get(0)); - buttons.get(0).addActionListener(e -> optionPane.setValue(JOptionPane.OK_OPTION)); - buttons.get(1).addActionListener(e -> optionPane.setValue(JOptionPane.OK_CANCEL_OPTION)); - } + JButton proceedButton = TRANSLATIONS.button("installer.button.proceed"); + JButton cancelButton = TRANSLATIONS.button("installer.button.cancel"); + JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, new Object[] { proceedButton, cancelButton, languageBox }); + + proceedButton.addActionListener(e -> optionPane.setValue(JOptionPane.OK_OPTION)); + cancelButton.addActionListener(e -> optionPane.setValue(JOptionPane.OK_CANCEL_OPTION)); + this.proceedButton = Optional.of(proceedButton); dialog = optionPane.createDialog(""); TRANSLATIONS.translate(dialog, new TranslationTarget<>(Dialog::setTitle), "installer.window.title", profile.getProfile());