mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix password fields
This commit is contained in:
+7
-1
@@ -18,6 +18,8 @@ import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.MINIMUM_HEIGHT;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -61,11 +63,15 @@ public class DarculaPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
|
||||
protected Dimension updatePreferredSize(Dimension size) {
|
||||
Insets i = getComponent().getInsets();
|
||||
size.height = Math.max(size.height, JBUI.scale(20) + i.top + i.bottom);
|
||||
size.height = Math.max(size.height, getMinimumHeight() + i.top + i.bottom);
|
||||
JBInsets.addTo(size, getComponent().getMargin());
|
||||
return size;
|
||||
}
|
||||
|
||||
protected int getMinimumHeight() {
|
||||
return MINIMUM_HEIGHT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
return getPreferredSize(c);
|
||||
|
||||
+5
-6
@@ -3,13 +3,14 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaPasswordFieldUI;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.intellij.ide.ui.laf.intellij.MacIntelliJTextBorder.MINIMUM_HEIGHT;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -44,10 +45,8 @@ public class MacIntelliJPasswordFieldUI extends DarculaPasswordFieldUI {
|
||||
}
|
||||
}
|
||||
|
||||
protected Dimension updatePreferredSize(Dimension size) {
|
||||
Insets i = getComponent().getInsets();
|
||||
size.height = Math.max(size.height, JBUI.scale(21) + i.top + i.bottom);
|
||||
JBInsets.addTo(size, getComponent().getMargin());
|
||||
return size;
|
||||
@Override
|
||||
protected int getMinimumHeight() {
|
||||
return MINIMUM_HEIGHT.get();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-21
@@ -16,22 +16,19 @@
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaPasswordFieldUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextBorder.MINIMUM_HEIGHT;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.HOVER_PROPERTY;
|
||||
|
||||
public class WinIntelliJPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
|
||||
public class WinIntelliJPasswordFieldUI extends DarculaPasswordFieldUI {
|
||||
private MouseListener hoverListener;
|
||||
private FocusListener focusListener;
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
@@ -42,18 +39,7 @@ public class WinIntelliJPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
super.installListeners();
|
||||
JTextComponent passwordField = getComponent();
|
||||
hoverListener = new DarculaUIUtil.MouseHoverPropertyTrigger(passwordField, HOVER_PROPERTY);
|
||||
focusListener = new FocusListener() {
|
||||
@Override public void focusGained(FocusEvent e) {
|
||||
passwordField.repaint();
|
||||
}
|
||||
|
||||
@Override public void focusLost(FocusEvent e) {
|
||||
passwordField.repaint();
|
||||
}
|
||||
};
|
||||
|
||||
passwordField.addMouseListener(hoverListener);
|
||||
passwordField.addFocusListener(focusListener);
|
||||
}
|
||||
|
||||
@Override public void uninstallListeners() {
|
||||
@@ -62,10 +48,6 @@ public class WinIntelliJPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
if (hoverListener != null) {
|
||||
passwordField.removeMouseListener(hoverListener);
|
||||
}
|
||||
|
||||
if (focusListener != null) {
|
||||
passwordField.removeFocusListener(focusListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,4 +69,9 @@ public class WinIntelliJPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMinimumHeight() {
|
||||
return MINIMUM_HEIGHT.get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user