Skip to content

Configure mnemonics for non-English yes/no buttons#14533

Open
rlament wants to merge 2 commits into
vassalengine:release-3.7from
rlament:optionpane-locale
Open

Configure mnemonics for non-English yes/no buttons#14533
rlament wants to merge 2 commits into
vassalengine:release-3.7from
rlament:optionpane-locale

Conversation

@rlament

@rlament rlament commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

This pull request addresses two related issues.

  1. English users can use mnemonic keys (Alt-Y/Alt-N) to answer yes/no prompts. For non-English locales the mnemonic keys have not been translated. This PR applies the translation.
  2. For a Yes-No-Cancel OptionPane where the buttons are assigned custom text, the mnemonic keys did not work at all for any locale. This PR enables the Yes/No mnemonics.

This image shows the before and after appearance of queries in German.
option_pane

Add mnemonics to begin log file prompt.
@uckelman uckelman added this to the 3.7.24 milestone Jun 9, 2026
});

yes.setPreferredSize(new Dimension(100, yes.getPreferredSize().height));
no.setPreferredSize(new Dimension(100, no.getPreferredSize().height));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is not right for the preferred width. That should depend on the font size and text length.

Isn't the way to do all of this setting the locale on JOptionPane?

https://stackoverflow.com/a/18189543/181106

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that when an options array of buttons is provided to JOptionPane the buttons are not formatted in the same way as buttons created internally by JOptionPane. Without resizing the buttons, the custom yes/no buttons appear smaller in width than in the existing dialog. Hard coding the dimension was my brute force attempt to make the buttons appear as before.

The buttons wrap the yes/no text, which is typically short words. Instead of hard coding a dimension, I changed this to double the left/right insets. This seems simpler than dealing with fonts and text lengths.

Isn't the way to do all of this setting the locale on JOptionPane?

I never got JOptionPane.setDefaultLocale() to work with custom buttons (i.e. dialogs that don't use the typical yes/no/cancel text). Where is did work, it didn't work for all supported languages. I don't recall the details as this was some time ago.

@uckelman uckelman modified the milestones: 3.7.24, 3.7.25 Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants