Skip to content

Commit

Permalink
Make Darklaf toolbar buttons thin
Browse files Browse the repository at this point in the history
This makes the toolbar much more compact yet still actionable
  • Loading branch information
vlsi committed Mar 19, 2020
1 parent f8ceb9c commit e2759e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,15 @@ protected NamePanel getNamePanel() {
* @return a JLabel which subclasses can add to their GUI
*/
protected Component createTitleLabel() {
JLabel titleLabel = new JLabel(getStaticLabel());
Font curFont = titleLabel.getFont();
titleLabel.setFont(curFont.deriveFont((float) curFont.getSize() + 4));
return titleLabel;
return new JLabel(getStaticLabel()) {
@Override
public void updateUI() {
super.updateUI();
// Setting the font in updateUI reduces UI jumps when look and feel changes
Font curFont = getFont();
setFont(curFont.deriveFont((float) curFont.getSize() + 4));
}
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.weisj.darklaf.ui.button.DarkButtonUI;

/**
* The JMeter main toolbar class
*
Expand Down Expand Up @@ -126,7 +128,18 @@ private static JButton makeButtonItemRes(IconToolbarBean iconBean) throws Except
if (imageURL == null) {
throw new Exception("No icon for: " + iconBean.getActionName());
}
JButton button = new JButton(new ImageIcon(imageURL));
JButton button = new JButton(new ImageIcon(imageURL)) {
@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_SHADOW);
putClientProperty(DarkButtonUI.KEY_THIN, true);
}
};
button.setToolTipText(JMeterUtils.getResString(iconBean.getI18nKey()));
final URL imageURLPressed = JMeterUtils.class.getClassLoader().getResource(iconBean.getIconPathPressed());
button.setPressedIcon(new ImageIcon(imageURLPressed));
Expand Down

0 comments on commit e2759e9

Please sign in to comment.