This is an automated email from the ASF dual-hosted git repository. pmouawad pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push: new 0c9606a Ensure all buttons added to the toolbar behave/look consistently. (#599) 0c9606a is described below commit 0c9606ad52fcfb259bfa4345c8f4e8cf6792f596 Author: Jannis Weis <31143295+we...@users.noreply.github.com> AuthorDate: Wed Jun 24 08:38:08 2020 +0200 Ensure all buttons added to the toolbar behave/look consistently. (#599) --- .../org/apache/jmeter/gui/util/JMeterToolBar.java | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java b/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java index af0e494..73a59b3 100644 --- a/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java +++ b/src/core/src/main/java/org/apache/jmeter/gui/util/JMeterToolBar.java @@ -91,6 +91,22 @@ public class JMeterToolBar extends JToolBar implements LocaleChangeListener { return toolBar; } + @Override + protected void addImpl(Component comp, Object constraints, int index) { + super.addImpl(comp, constraints, index); + if (comp instanceof JButton) { + // Ensure buttons added to the toolbar have the same style. + JButton b = (JButton) comp; + b.setFocusable(false); + if (b.isBorderPainted() && (b.getText() == null || b.getText().isEmpty())) { + b.setRolloverEnabled(true); + b.putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS); + b.putClientProperty(DarkButtonUI.KEY_THIN, true); + b.putClientProperty(DarkButtonUI.KEY_SQUARE, true); + } + } + } + /** * Setup toolbar content * @param toolBar {@link JMeterToolBar} @@ -128,18 +144,7 @@ public class JMeterToolBar extends JToolBar implements LocaleChangeListener { * @return a button for toolbar */ private static JButton makeButtonItemRes(IconToolbarBean iconBean) throws Exception { - JButton button = new JButton(loadIcon(iconBean, iconBean.getIconPath())) { - @Override - public void updateUI() { - super.updateUI(); - // Certain LaFs might alter button configuration, so we revert it to the way we want - // For instance, https://github.com/weisJ/darklaf/issues/84 - setFocusable(false); - setRolloverEnabled(true); - putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS); - putClientProperty(DarkButtonUI.KEY_THIN, true); - } - }; + JButton button = new JButton(loadIcon(iconBean, iconBean.getIconPath())); button.setToolTipText(JMeterUtils.getResString(iconBean.getI18nKey())); if (!iconBean.getIconPathPressed().equals(iconBean.getIconPath())) { button.setPressedIcon(loadIcon(iconBean, iconBean.getIconPathPressed()));