Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Installer when using Nimbus LookAndFeel #15

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions src/main/java/net/minecraftforge/installer/ui/InstallerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<JButton> 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());
Expand Down
Loading