删除 src/main/java/com/bonus/autoweb/UI/frame/MyFocusListener.java

This commit is contained in:
tqzhang 2024-05-07 16:48:43 +08:00
parent bd73da6007
commit 54bf53f0db
1 changed files with 0 additions and 34 deletions

View File

@ -1,34 +0,0 @@
package com.bonus.autoweb.UI.frame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class MyFocusListener implements FocusListener {
String info;
JTextField jtf;
public MyFocusListener(String info, JTextField jtf){
this.info=info;
this.jtf=jtf;
jtf.setForeground(new Color(105,105,105));
jtf.setText(info);
}
@Override
public void focusGained(FocusEvent e){//获得焦点的时候,清空提示文字
jtf.setFont(new Font("微软雅黑",Font.BOLD,50));
jtf.setForeground(Color.BLACK);
String temp=jtf.getText();
if(temp.equals(info)){
jtf.setText("");
}
}
public void focusLost(FocusEvent e){//失去焦点的时候,判断如果为空,就显示提示文字
String temp=jtf.getText();
if(temp.equals("")){
jtf.setFont(new Font("微软雅黑",Font.BOLD,50));
jtf.setForeground(new Color(105,105,105));
jtf.setText(info);
}
}
}