Browse Source

密码输入框边框颜色修改

master
hzzz 7 years ago
parent
commit
b99265cf87
  1. 3
      designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java
  2. 47
      designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java

3
designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java

@ -4,6 +4,7 @@
package com.fr.design.gui.borders;
import com.fr.design.constants.UIConstants;
import com.fr.design.utils.DrawRoutines;
import com.fr.design.utils.ThemeUtils;
@ -54,7 +55,7 @@ public class UITextFieldBorder extends AbstractBorder implements UIResource {
g, ThemeUtils.TEXT_BORDER_DISABLED_COLOR, x, y, w, h);
} else {
DrawRoutines.drawBorder(
g, ThemeUtils.TEXT_BORDER_COLOR, x, y, w, h);
g, UIConstants.POP_DIALOG_BORDER, x, y, w, h);
}
}
}

47
designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java

@ -1,8 +1,13 @@
package com.fr.design.gui.ipasswordfield;
import com.fr.design.constants.UIConstants;
import javax.swing.*;
import javax.swing.text.Document;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created with IntelliJ IDEA.
@ -12,24 +17,56 @@ import javax.swing.text.Document;
* To change this template use File | Settings | File Templates.
*/
public class UIPassWordField extends JPasswordField {
private boolean isRollOver;
public UIPassWordField () {
public UIPassWordField() {
super();
addRollOverListener();
}
public UIPassWordField (String text) {
public UIPassWordField(String text) {
super(text);
addRollOverListener();
}
public UIPassWordField (int columns) {
public UIPassWordField(int columns) {
super(columns);
addRollOverListener();
}
public UIPassWordField (String text, int columns) {
public UIPassWordField(String text, int columns) {
super(text, columns);
addRollOverListener();
}
public UIPassWordField (Document doc, String txt, int columns) {
public UIPassWordField(Document doc, String txt, int columns) {
super(doc, txt, columns);
addRollOverListener();
}
private void addRollOverListener() {
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
isRollOver = true;
UIPassWordField.this.repaint();
}
@Override
public void mouseExited(MouseEvent e) {
isRollOver = false;
UIPassWordField.this.repaint();
}
});
}
@Override
protected void paintBorder(Graphics g) {
if (isRollOver && this.isEnabled()) {
g.setColor(UIConstants.TEXT_FILED_BORDER_SELECTED);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
} else {
super.paintBorder(g);
}
}
}
Loading…
Cancel
Save