点击看不清楚,换一张为什么图片不换啊
package login;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Checking extends JFrame implements MouseListener{
/**
*
*/
private static final long serialVersionUID = 1L;
JLabel l=new JLabel();
JLabel changecode=new JLabel("看不清楚,换一张");
JLabel a=new JLabel("输入验证码:");
JTextField jtf=new JTextField();
JButton ok=new JButton("确定");
public Checking(){
this.setLayout(null);
l.setBounds(0, 0, 200, 70);
a.setBounds(10, 75, 80, 35);
jtf.setBounds(10, 110, 130, 35);
ok.setBounds(180, 110, 80, 30);
changecode.setBounds(220,25,100,40);
this.add(ok);
this.add(jtf);
this.add(a);
this.add(l);
this.add(changecode);
this.setSize(350, 200);
this.setVisible(true);
this.setResizable(false);
this.setLocationRelativeTo(null);
changecode.addMouseListener(this);
}
public static void main(String[] args){
new Checking();
}
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==changecode){
new MyCheckCode();
l.setIcon(new ImageIcon("E://Demo//picture//checkcode.jpg"));
}
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==changecode)
changecode.setForeground(Color.red);
}
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==changecode)
changecode.setForeground(Color.BLACK);
}
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseMoved(MouseEvent e) {
// TODO Auto-generated method stub
}
}
|
|