On Wed, 1 Jun 2022 06:00:34 GMT, Tejesh R <[email protected]> wrote:
>> Added test for checking setMargin() of JRadioButton.
>
> Tejesh R has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Updated based on review comments
Changes requested by aivanov (Reviewer).
Shall the test be located in
`test/jdk/javax/swing/JRadioButton/4380543/bug4380543.java`
instead of
`test/jdk/javax/swing/JRadioButton/bug4380543.java` ?
Usually, there's been a folder with bugid (`/4380543/`) for each test. Do we
use the flat layout now?
test/jdk/javax/swing/JRadioButton/bug4380543.java line 62:
> 60: "(insets set to 20 on all 4 sides)." +
> 61: "\n 3. If Left insets(margins) appear Empty, press Fail, " +
> 62: "else press Pass.";
You should add an explicit step to verify rendering in different Look-and-Feels
by clicking the buttons.
test/jdk/javax/swing/JRadioButton/bug4380543.java line 102:
> 100: sLnFName = sLnFName.trim();
> 101:
> 102: lookAndFeelMap.put(sLnFName, sLnFClassName);
Why don't you want to use `look.getName()` instead of doing the magic to
extract what resembles the name from the class?
test/jdk/javax/swing/JRadioButton/bug4380543.java line 126:
> 124:
> 125: for (Map.Entry<String, String> mapElement :
> lookAndFeelMap.entrySet()) {
> 126: String btnName = mapElement.getKey();
This can be further simplified: you don't use the value, you use only the key,
so the for-loop could iterate over `lookAndFeelMap.keySet()`.
In fact, you can avoid the map altogether if you use the class name as the
action name:
UIManager.LookAndFeelInfo[] lookAndFeel = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo look : lookAndFeel) {
JButton btn = new JButton(look.getName());
btn.setActionCommand(look.getClassName());
btn.addActionListener(this);
p.add(btn);
}
In this case, `initMap` and `lookAndFeelMap` should be removed.
The listener should be updated:
public void actionPerformed(ActionEvent e) {
setLookAndFeel(e.getActionCommand());
SwingUtilities.updateComponentTreeUI(this);
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/8721