mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add a listener to make help buttons non-opaque
This commit is contained in:
+29
-1
@@ -21,20 +21,48 @@ import sun.swing.SwingUtilities2;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class WinIntelliJButtonUI extends DarculaButtonUI {
|
||||
private PropertyChangeListener helpButtonListener = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
final Object source = evt.getSource();
|
||||
if (source instanceof AbstractButton) {
|
||||
if (isHelpButton((JComponent)source)) {
|
||||
((AbstractButton)source).setOpaque(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WinIntelliJButtonUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installListeners(AbstractButton b) {
|
||||
super.installListeners(b);
|
||||
b.addPropertyChangeListener("JButton.buttonType", helpButtonListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallListeners(AbstractButton b) {
|
||||
b.removePropertyChangeListener("JButton.buttonType", helpButtonListener);
|
||||
super.uninstallListeners(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean paintDecorations(Graphics2D g, JComponent c) {
|
||||
if (isHelpButton(c)) {
|
||||
return super.paintDecorations(g, c);
|
||||
final Icon help = MacIntelliJIconCache.getIcon("winHelp");
|
||||
help.paintIcon(c, g, (c.getWidth() - help.getIconWidth()) / 2, (c.getHeight() - help.getIconHeight()) / 2);
|
||||
return false;
|
||||
}
|
||||
final Insets i = c.getInsets();
|
||||
g.setColor(c.hasFocus() ? UIManager.getColor("Button.intellij.native.activeBackgroundColor") : c.getBackground());
|
||||
|
||||
Reference in New Issue
Block a user