Skip to content

Commit

Permalink
fix action's update for toolbar's buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Jan 12, 2024
1 parent 1942bcc commit 2e09f20
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/studio/ui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.apache.logging.log4j.Logger;

import javax.swing.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

public class Toolbar extends JToolBar {

Expand All @@ -16,6 +14,12 @@ public JButton add(Action a) {
JButton btn = super.add(a);
updateTooltipTest(btn);

a.addPropertyChangeListener( e-> {
if (e.getPropertyName() == Action.ACCELERATOR_KEY) {
updateTooltipTest(btn);
}
});

return btn;
}

Expand All @@ -30,15 +34,4 @@ private void updateTooltipTest(JButton btn) {
btn.setToolTipText(tooltip);
}

@Override
protected PropertyChangeListener createActionChangeListener(JButton b) {
return new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName() == Action.ACCELERATOR_KEY) {
updateTooltipTest(b);
}
}
};
}
}

0 comments on commit 2e09f20

Please sign in to comment.