论坛首页 Java企业应用论坛

java软键盘源码测试

浏览 2829 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2009-01-31   最后修改:2009-10-23
package com.botaisoft.util;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.border.Border;

import com.pdm.login.Login;

/**
 * <br>版权:G博士
 * <br>作者:G博士 
 * <br>邮件:332905115@qq.com
 * */
public class Keyboard  extends JDialog implements MouseListener,ActionListener{

	private static final long serialVersionUID = 1L;
	@SuppressWarnings("unused")
	private boolean flg = false;
	@SuppressWarnings("unused")
	private boolean flgs = false;
	private Login lg = null;
	private int i=1;
	private int j=1;
	private Color fcolor = Color.RED;
	private Color color = Color.BLACK;
	private JLabel t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,Backspace;
	private JLabel Q,W,E,R,T,Y,U,I,O,P,Thr1,Thr2,Thr3;
	private JLabel Caps,A,S,D,F,G,H,J,K,L,FO1,FO2,FO3;
	private JLabel Shift,Z,X,C,V,BS,N,M,FI1,FI2;
	
	public static String superstr;
	
	public Keyboard(JFrame frame){
		super (frame, "屏幕键盘-网络小助�",true);
		start();
	}
	public void start(){
		this.setBounds(375,330,450,150);
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent we) {
		    	setVisible(false);
		    	dispose();
			}
		});
		this.getContentPane().setLayout(null);
		this.setResizable (false);
		Border B = BorderFactory.createEtchedBorder();
		
		t1 = new JLabel("1");
		t1.setHorizontalAlignment(JLabel.CENTER);
		t1.setBorder(B);
		t1.addMouseListener(this);
		t1.setBounds(new Rectangle(2, 2, 25, 25));
		this.getContentPane().add(t1);
		
		t2 = new JLabel("2");
		t2.setHorizontalAlignment(JLabel.CENTER);
		t2.setBorder(B);
		t2.addMouseListener(this);
		t2.setBounds(new Rectangle(32, 2, 25, 25));
		this.getContentPane().add(t2);
		
		t3 = new JLabel("3");
		t3.setHorizontalAlignment(JLabel.CENTER);
		t3.setBorder(B);
		t3.addMouseListener(this);
		t3.setBounds(new Rectangle(62, 2, 25, 25));
		this.getContentPane().add(t3);
		
		t4 = new JLabel("4");
		t4.setHorizontalAlignment(JLabel.CENTER);
		t4.setBorder(B);
		t4.addMouseListener(this);
		t4.setBounds(new Rectangle(92, 2, 25, 25));
		this.getContentPane().add(t4);
		
		t5 = new JLabel("5");
		t5.setHorizontalAlignment(JLabel.CENTER);
		t5.setBorder(B);
		t5.addMouseListener(this);
		t5.setBounds(new Rectangle(122, 2, 25, 25));
		this.getContentPane().add(t5);
		
		t6 = new JLabel("6");
		t6.setHorizontalAlignment(JLabel.CENTER);
		t6.setBorder(B);
		t6.addMouseListener(this);
		t6.setBounds(new Rectangle(152, 2, 25, 25));
		this.getContentPane().add(t6);
		
		t7 = new JLabel("7");
		t7.setHorizontalAlignment(JLabel.CENTER);
		t7.setBorder(B);
		t7.addMouseListener(this);
		t7.setBounds(new Rectangle(182, 2, 25, 25));
		this.getContentPane().add(t7);
		
		t8 = new JLabel("8");
		t8.setHorizontalAlignment(JLabel.CENTER);
		t8.setBorder(B);
		t8.addMouseListener(this);
		t8.setBounds(new Rectangle(212, 2, 25, 25));
		this.getContentPane().add(t8);
		
		t9 = new JLabel("9");
		t9.setHorizontalAlignment(JLabel.CENTER);
		t9.setBorder(B);
		t9.addMouseListener(this);
		t9.setBounds(new Rectangle(242, 2, 25, 25));
		this.getContentPane().add(t9);
		
		t0 = new JLabel("0");
		t0.setHorizontalAlignment(JLabel.CENTER);
		t0.setBorder(B);
		t0.addMouseListener(this);
		t0.setBounds(new Rectangle(272, 2, 25, 25));
		this.getContentPane().add(t0);
		
		t10 = new JLabel("-");
		t10.setHorizontalAlignment(JLabel.CENTER);
		t10.setBorder(B);
		t10.addMouseListener(this);
		t10.setBounds(new Rectangle(302, 2, 25, 25));
		this.getContentPane().add(t10);
		
		t11 = new JLabel("=");
		t11.setHorizontalAlignment(JLabel.CENTER);
		t11.setBorder(B);
		t11.addMouseListener(this);
		t11.setBounds(new Rectangle(332, 2, 25, 25));
		this.getContentPane().add(t11);
		
		Backspace = new JLabel("<--清除文本");
		Backspace.setHorizontalAlignment(JLabel.CENTER);
		Backspace.setBorder(B);
		Backspace.addMouseListener(this);
		Backspace.setBounds(new Rectangle(362, 2, 80, 25));
		this.getContentPane().add(Backspace);
		
		Q = new JLabel("q");
		Q.setHorizontalAlignment(JLabel.CENTER);
		Q.setBorder(B);
		Q.addMouseListener(this);
		Q.setBounds(new Rectangle(2, 32, 25, 25));
		this.getContentPane().add(Q);
		
		W = new JLabel("w");
		W.setHorizontalAlignment(JLabel.CENTER);
		W.setBorder(B);
		W.addMouseListener(this);
		W.setBounds(new Rectangle(27, 32, 25, 25));
		this.getContentPane().add(W);
		
		E = new JLabel("e");
		E.setHorizontalAlignment(JLabel.CENTER);
		E.setBorder(B);
		E.addMouseListener(this);
		E.setBounds(new Rectangle(52, 32, 25, 25));
		this.getContentPane().add(E);
		
		R = new JLabel("r");
		R.setHorizontalAlignment(JLabel.CENTER);
		R.setBorder(B);
		R.addMouseListener(this);
		R.setBounds(new Rectangle(77, 32, 25, 25));
		this.getContentPane().add(R);
		
		T = new JLabel("t");
		T.setHorizontalAlignment(JLabel.CENTER);
		T.setBorder(B);
		T.addMouseListener(this);
		T.setBounds(new Rectangle(102, 32, 25, 25));
		this.getContentPane().add(T);
		
		Y = new JLabel("y");
		Y.setHorizontalAlignment(JLabel.CENTER);
		Y.setBorder(B);
		Y.addMouseListener(this);
		Y.setBounds(new Rectangle(127, 32, 25, 25));
		this.getContentPane().add(Y);
		
		U = new JLabel("u");
		U.setHorizontalAlignment(JLabel.CENTER);
		U.setBorder(B);
		U.addMouseListener(this);
		U.setBounds(new Rectangle(152, 32, 25, 25));
		this.getContentPane().add(U);
		
		I = new JLabel("i");
		I.setHorizontalAlignment(JLabel.CENTER);
		I.setBorder(B);
		I.addMouseListener(this);
		I.setBounds(new Rectangle(177, 32, 25, 25));
		this.getContentPane().add(I);
		
		O = new JLabel("o");
		O.setHorizontalAlignment(JLabel.CENTER);
		O.setBorder(B);
		O.addMouseListener(this);
		O.setBounds(new Rectangle(202, 32, 25, 25));
		this.getContentPane().add(O);
		
		P = new JLabel("p");
		P.setHorizontalAlignment(JLabel.CENTER);
		P.setBorder(B);
		P.addMouseListener(this);
		P.setBounds(new Rectangle(227, 32, 25, 25));
		this.getContentPane().add(P);
		
		Thr1 = new JLabel("{");
		Thr1.setHorizontalAlignment(JLabel.CENTER);
		Thr1.setBorder(B);
		Thr1.addMouseListener(this);
		Thr1.setBounds(new Rectangle(255, 32, 55, 25));
		this.getContentPane().add(Thr1);
		
		Thr2 = new JLabel("}");
		Thr2.setHorizontalAlignment(JLabel.CENTER);
		Thr2.setBorder(B);
		Thr2.addMouseListener(this);
		Thr2.setBounds(new Rectangle(310, 32, 55, 25));
		this.getContentPane().add(Thr2);
		
		Thr3 = new JLabel("|");
		Thr3.setHorizontalAlignment(JLabel.CENTER);
		Thr3.setBorder(B);
		Thr3.addMouseListener(this);
		Thr3.setBounds(new Rectangle(365, 32, 77, 25));
		this.getContentPane().add(Thr3);

		Caps = new JLabel("锁定大写");
		Caps.setHorizontalAlignment(JLabel.CENTER);
		Caps.setBorder(B);
		Caps.setBounds(new Rectangle(227, 92, 110, 25));
		Caps.addMouseListener(this);
		this.getContentPane().add(Caps);
		
		
		A = new JLabel("a");
		A.setHorizontalAlignment(JLabel.CENTER);
		A.setBorder(B);
		A.addMouseListener(this);
		A.setBounds(new Rectangle(2, 62, 25, 25));
		this.getContentPane().add(A);
		
		
		S = new JLabel("s");
		S.setHorizontalAlignment(JLabel.CENTER);
		S.setBorder(B);
		S.addMouseListener(this);
		S.setBounds(new Rectangle(27, 62, 25, 25));
		this.getContentPane().add(S);
		
		D = new JLabel("d");
		D.setHorizontalAlignment(JLabel.CENTER);
		D.setBorder(B);
		D.addMouseListener(this);
		D.setBounds(new Rectangle(52, 62, 25, 25));
		this.getContentPane().add(D);
		
		F = new JLabel("f");
		F.setHorizontalAlignment(JLabel.CENTER);
		F.setBorder(B);
		F.addMouseListener(this);
		F.setBounds(new Rectangle(77, 62, 25, 25));
		this.getContentPane().add(F);
		
		G = new JLabel("g");
		G.setHorizontalAlignment(JLabel.CENTER);
		G.setBorder(B);
		G.addMouseListener(this);
		G.setBounds(new Rectangle(102, 62, 25, 25));
		this.getContentPane().add(G);
		
		H = new JLabel("h");
		H.setHorizontalAlignment(JLabel.CENTER);
		H.setBorder(B);
		H.addMouseListener(this);
		H.setBounds(new Rectangle(127, 62, 25, 25));
		this.getContentPane().add(H);
		
		J = new JLabel("j");
		J.setHorizontalAlignment(JLabel.CENTER);
		J.setBorder(B);
		J.addMouseListener(this);
		J.setBounds(new Rectangle(152, 62, 25, 25));
		this.getContentPane().add(J);
		
		K = new JLabel("k");
		K.setHorizontalAlignment(JLabel.CENTER);
		K.setBorder(B);
		K.addMouseListener(this);
		K.setBounds(new Rectangle(177, 62, 25, 25));
		this.getContentPane().add(K);
		
		L = new JLabel("l");
		L.setHorizontalAlignment(JLabel.CENTER);
		L.setBorder(B);
		L.addMouseListener(this);
		L.setBounds(new Rectangle(202, 62, 25, 25));
		this.getContentPane().add(L);
		
		FO1 = new JLabel(";");
		FO1.setHorizontalAlignment(JLabel.CENTER);
		FO1.setBorder(B);
		FO1.addMouseListener(this);
		FO1.setBounds(new Rectangle(227, 62, 25, 25));
		this.getContentPane().add(FO1);
		
		FO2 = new JLabel("'");
		FO2.setHorizontalAlignment(JLabel.CENTER);
		FO2.setBorder(B);
		FO2.addMouseListener(this);
		FO2.setBounds(new Rectangle(252, 62, 40, 25));
		this.getContentPane().add(FO2);
		
		
		FO3 = new JLabel("确定输入并�??�?<--");
		FO3.setHorizontalAlignment(JLabel.CENTER);
		FO3.setBorder(B);
		FO3.addMouseListener(this);
		FO3.setBounds(new Rectangle(292, 62, 150, 25));
		this.getContentPane().add(FO3);

		Shift = new JLabel("符号切换");
		Shift.setHorizontalAlignment(JLabel.CENTER);
		Shift.setBorder(B);
		Shift.addMouseListener(this);
		Shift.setBounds(new Rectangle(337,92, 105, 25));
		this.getContentPane().add(Shift);
		
		Z = new JLabel("z");
		Z.setHorizontalAlignment(JLabel.CENTER);
		Z.setBorder(B);
		Z.addMouseListener(this);
		Z.setBounds(new Rectangle(2, 92, 25, 25));
		this.getContentPane().add(Z);
		
		X = new JLabel("x");
		X.setHorizontalAlignment(JLabel.CENTER);
		X.setBorder(B);
		X.addMouseListener(this);
		X.setBounds(new Rectangle(27, 92, 25, 25));
		this.getContentPane().add(X);
		
		C = new JLabel("c");
		C.setHorizontalAlignment(JLabel.CENTER);
		C.setBorder(B);
		C.addMouseListener(this);
		C.setBounds(new Rectangle(52, 92, 25, 25));
		this.getContentPane().add(C);
		
		V = new JLabel("v");
		V.setHorizontalAlignment(JLabel.CENTER);
		V.setBorder(B);
		V.addMouseListener(this);
		V.setBounds(new Rectangle(77, 92, 25, 25));
		this.getContentPane().add(V);
		
		BS = new JLabel("b");
		BS.setHorizontalAlignment(JLabel.CENTER);
		BS.setBorder(B);
		BS.addMouseListener(this);
		BS.setBounds(new Rectangle(102, 92, 25, 25));
		this.getContentPane().add(BS);
		
		N = new JLabel("n");
		N.setHorizontalAlignment(JLabel.CENTER);
		N.setBorder(B);
		N.addMouseListener(this);
		N.setBounds(new Rectangle(127, 92, 25, 25));
		this.getContentPane().add(N);
		
		M = new JLabel("m");
		M.setHorizontalAlignment(JLabel.CENTER);
		M.setBorder(B);
		M.addMouseListener(this);
		M.setBounds(new Rectangle(152, 92, 25, 25));
		this.getContentPane().add(M);
		
		FI1 = new JLabel(",");
		FI1.setHorizontalAlignment(JLabel.CENTER);
		FI1.setBorder(B);
		FI1.addMouseListener(this);
		FI1.setBounds(new Rectangle(177, 92, 25, 25));
		this.getContentPane().add(FI1);
		
		FI2 = new JLabel(".");
		FI2.setHorizontalAlignment(JLabel.CENTER);
		FI2.setBorder(B);
		FI2.addMouseListener(this);
		FI2.setBounds(new Rectangle(202, 92, 25, 25));
		this.getContentPane().add(FI2);
		com.pdm.style.Theme.setWindowkey(this);
		this.setVisible(true);
	}
	public void actionPerformed(ActionEvent e) {

	}
	public void mouseClicked(MouseEvent e){}
	public void mouseEntered(MouseEvent e) {
		//鼠标进入到组件上时调用�??
		//设置颜色
		if(e.getSource()==Shift){Shift.setForeground(fcolor);}
		if(e.getSource()==Z){Z.setForeground(fcolor);}
		if(e.getSource()==X){X.setForeground(fcolor);}
		if(e.getSource()==C){C.setForeground(fcolor);}
		if(e.getSource()==V){V.setForeground(fcolor);}
		if(e.getSource()==BS){BS.setForeground(fcolor);}
		if(e.getSource()==N){N.setForeground(fcolor);}
		if(e.getSource()==M){M.setForeground(fcolor);}
		if(e.getSource()==FI1){FI1.setForeground(fcolor);}
		if(e.getSource()==FI2){FI2.setForeground(fcolor);}
		if(e.getSource()==W){W.setForeground(fcolor);}
		if(e.getSource()==E){E.setForeground(fcolor);}
		if(e.getSource()==R){R.setForeground(fcolor);}
		if(e.getSource()==T){T.setForeground(fcolor);}
		if(e.getSource()==Y){Y.setForeground(fcolor);}
		if(e.getSource()==U){U.setForeground(fcolor);}
		if(e.getSource()==I){I.setForeground(fcolor);}
		if(e.getSource()==O){O.setForeground(fcolor);}
		if(e.getSource()==P){P.setForeground(fcolor);}
		if(e.getSource()==Thr1){Thr1.setForeground(fcolor);}
		if(e.getSource()==Thr2){Thr2.setForeground(fcolor);}
		if(e.getSource()==Thr3){Thr3.setForeground(fcolor);}
		if(e.getSource()==A){A.setForeground(fcolor);}
		if(e.getSource()==S){S.setForeground(fcolor);}
		if(e.getSource()==D){D.setForeground(fcolor);}
		if(e.getSource()==F){F.setForeground(fcolor);}
		if(e.getSource()==G){G.setForeground(fcolor);}
		if(e.getSource()==H){H.setForeground(fcolor);}
		if(e.getSource()==J){J.setForeground(fcolor);}
		if(e.getSource()==K){K.setForeground(fcolor);}
		if(e.getSource()==L){L.setForeground(fcolor);}
		if(e.getSource()==FO1){FO1.setForeground(fcolor);}
		if(e.getSource()==FO2){FO2.setForeground(fcolor);}
		if(e.getSource()==FO3){FO3.setForeground(fcolor);}
		if(e.getSource()==Caps){Caps.setForeground(fcolor);}
		if(e.getSource()==t0){t0.setForeground(fcolor);}
		if(e.getSource()==t1){t1.setForeground(fcolor);}
		if(e.getSource()==t2){t2.setForeground(fcolor);}
		if(e.getSource()==t3){t3.setForeground(fcolor);}
		if(e.getSource()==t4){t4.setForeground(fcolor);}
		if(e.getSource()==t5){t5.setForeground(fcolor);}
		if(e.getSource()==t6){t6.setForeground(fcolor);}
		if(e.getSource()==t7){t7.setForeground(fcolor);}
		if(e.getSource()==t8){t8.setForeground(fcolor);}
		if(e.getSource()==t9){t9.setForeground(fcolor);}
		if(e.getSource()==t10){t10.setForeground(fcolor);}
		if(e.getSource()==t11){t11.setForeground(fcolor);}
		if(e.getSource()==Backspace){Backspace.setForeground(fcolor);}
		if(e.getSource()==Q){Q.setForeground(fcolor);}
		if(e.getSource()==W){W.setForeground(fcolor);}
	}
	public void mouseExited(MouseEvent e) {
		//鼠标离开组件时调用�??
		//恢复颜色
		if(e.getSource()==Shift){Shift.setForeground(color);}
		if(e.getSource()==Z){Z.setForeground(color);}
		if(e.getSource()==X){X.setForeground(color);}
		if(e.getSource()==C){C.setForeground(color);}
		if(e.getSource()==V){V.setForeground(color);}
		if(e.getSource()==BS){BS.setForeground(color);}
		if(e.getSource()==N){N.setForeground(color);}
		if(e.getSource()==M){M.setForeground(color);}
		if(e.getSource()==FI1){FI1.setForeground(color);}
		if(e.getSource()==FI2){FI2.setForeground(color);}
		if(e.getSource()==W){W.setForeground(color);}
		if(e.getSource()==E){E.setForeground(color);}
		if(e.getSource()==R){R.setForeground(color);}
		if(e.getSource()==T){T.setForeground(color);}
		if(e.getSource()==Y){Y.setForeground(color);}
		if(e.getSource()==U){U.setForeground(color);}
		if(e.getSource()==I){I.setForeground(color);}
		if(e.getSource()==O){O.setForeground(color);}
		if(e.getSource()==P){P.setForeground(color);}
		if(e.getSource()==Thr1){Thr1.setForeground(color);}
		if(e.getSource()==Thr2){Thr2.setForeground(color);}
		if(e.getSource()==Thr3){Thr3.setForeground(color);}
		if(e.getSource()==A){A.setForeground(color);}
		if(e.getSource()==S){S.setForeground(color);}
		if(e.getSource()==D){D.setForeground(color);}
		if(e.getSource()==F){F.setForeground(color);}
		if(e.getSource()==G){G.setForeground(color);}
		if(e.getSource()==H){H.setForeground(color);}
		if(e.getSource()==J){J.setForeground(color);}
		if(e.getSource()==K){K.setForeground(color);}
		if(e.getSource()==L){L.setForeground(color);}
		if(e.getSource()==FO1){FO1.setForeground(color);}
		if(e.getSource()==FO2){FO2.setForeground(color);}
		if(e.getSource()==FO3){FO3.setForeground(color);}
		if(e.getSource()==Caps){Caps.setForeground(color);}
		if(e.getSource()==t0){t0.setForeground(color);}
		if(e.getSource()==t1){t1.setForeground(color);}
		if(e.getSource()==t2){t2.setForeground(color);}
		if(e.getSource()==t3){t3.setForeground(color);}
		if(e.getSource()==t4){t4.setForeground(color);}
		if(e.getSource()==t5){t5.setForeground(color);}
		if(e.getSource()==t6){t6.setForeground(color);}
		if(e.getSource()==t7){t7.setForeground(color);}
		if(e.getSource()==t8){t8.setForeground(color);}
		if(e.getSource()==t9){t9.setForeground(color);}
		if(e.getSource()==t10){t10.setForeground(color);}
		if(e.getSource()==t11){t11.setForeground(color);}
		if(e.getSource()==Backspace){Backspace.setForeground(color);}
		if(e.getSource()==Q){Q.setForeground(color);}
		if(e.getSource()==W){W.setForeground(color);}
	}
	@SuppressWarnings("static-access")
	public void mousePressed(MouseEvent e) {// 鼠标按键在组件上按下时调用�??
		
		//监听大小写并且切�?
		if(e.getSource()==Caps){
			if(i==1){
				flg = true;
				W.setText("W");E.setText("E");R.setText("R");T.setText("T");Y.setText("Y");
				U.setText("U");I.setText("I");O.setText("O");P.setText("P");A.setText("A");
				S.setText("S");D.setText("D");F.setText("F");G.setText("G");H.setText("H");
				J.setText("J");K.setText("K");L.setText("L");Z.setText("Z");X.setText("X");
				C.setText("C");V.setText("V");BS.setText("B");N.setText("N");M.setText("M");
				Q.setText("Q");
				JOptionPane.showMessageDialog(null, "注意:键盘字符已经锁定大写!"); 
			i=2;
			}else{
				flg = false;
				W.setText("w");E.setText("e");R.setText("r");T.setText("t");Y.setText("y");
				U.setText("u");I.setText("i");O.setText("o");P.setText("p");A.setText("a");
				S.setText("s");D.setText("d");F.setText("f");G.setText("g");H.setText("h");
				J.setText("j");K.setText("k");L.setText("l");Z.setText("z");X.setText("x");
				C.setText("c");V.setText("v");BS.setText("b");N.setText("n");M.setText("m");
				Q.setText("q");
				JOptionPane.showMessageDialog(null, "注意:键盘字符已经锁定小写!"); 
			i=1;
			}
		}
		/**
		 * 监听数字与符号并且相互切�?
		 * */
		if(e.getSource()==Shift){
			if(j==1){
				flgs = true;
				t0.setText("!");t1.setText("@");t2.setText("#");t3.setText("$");t4.setText("%");
				t5.setText("^");t6.setText("&");t7.setText("*");t8.setText("(");t9.setText(")");
				t10.setText("_");t11.setText("+");Thr1.setText("[");Thr2.setText("]");
				Thr3.setText("\\");FO1.setText(":");FO2.setText("'");FI1.setText("<");
				FI2.setText(">");
				JOptionPane.showMessageDialog(null, "注意:数字已经切换到符号操作�?"); 
			j=2;	
			}else{
				flgs = false;
				t0.setText("0");t1.setText("1");t2.setText("2");t3.setText("3");
				t4.setText("4");t5.setText("5");t6.setText("6");t7.setText("7");
				t8.setText("8");t9.setText("9");t10.setText("-");t11.setText("=");
				Thr1.setText("{");Thr2.setText("}");Thr3.setText("|");FO1.setText(";");
				FO2.setText("�?");FI1.setText(",");FI2.setText(".");
				JOptionPane.showMessageDialog(null, "注意:符号已经切换到数字操作�?"); 
			j=1;
			}
		}
		/**
		 * 设置按键的字母字�?
		 * */
		if(e.getSource()==Q){String s = getstring();lg.password.setText(s+Q.getText());}
		if(e.getSource()==W){String s = getstring();lg.password.setText(s+W.getText());}
		if(e.getSource()==E){String s = getstring();lg.password.setText(s+E.getText());}
		if(e.getSource()==R){String s = getstring();lg.password.setText(s+R.getText());}
		if(e.getSource()==T){String s = getstring();lg.password.setText(s+T.getText());}
		if(e.getSource()==Y){String s = getstring();lg.password.setText(s+Y.getText());}
		if(e.getSource()==U){String s = getstring();lg.password.setText(s+U.getText());}
		if(e.getSource()==I){String s = getstring();lg.password.setText(s+I.getText());}
		if(e.getSource()==O){String s = getstring();lg.password.setText(s+O.getText());}
		if(e.getSource()==P){String s = getstring();lg.password.setText(s+P.getText());}
		if(e.getSource()==A){String s = getstring();lg.password.setText(s+A.getText());}
		if(e.getSource()==S){String s = getstring();lg.password.setText(s+S.getText());}
		if(e.getSource()==D){String s = getstring();lg.password.setText(s+D.getText());}
		if(e.getSource()==F){String s = getstring();lg.password.setText(s+F.getText());}
		if(e.getSource()==G){String s = getstring();lg.password.setText(s+G.getText());}
		if(e.getSource()==H){String s = getstring();lg.password.setText(s+H.getText());}
		if(e.getSource()==J){String s = getstring();lg.password.setText(s+J.getText());}
		if(e.getSource()==K){String s = getstring();lg.password.setText(s+K.getText());}
		if(e.getSource()==L){String s = getstring();lg.password.setText(s+L.getText());}
		if(e.getSource()==Z){String s = getstring();lg.password.setText(s+Z.getText());}
		if(e.getSource()==X){String s = getstring();lg.password.setText(s+X.getText());}
		if(e.getSource()==C){String s = getstring();lg.password.setText(s+C.getText());}
		if(e.getSource()==V){String s = getstring();lg.password.setText(s+V.getText());}
		if(e.getSource()==BS){String s = getstring();lg.password.setText(s+BS.getText());}
		if(e.getSource()==N){String s = getstring();lg.password.setText(s+N.getText());}
		if(e.getSource()==M){String s = getstring();lg.password.setText(s+M.getText());}
		/**
		 * 设置按键的符�?
		 * */
		if(e.getSource()==t0){String s = getstring();lg.password.setText(s+t0.getText());}
		if(e.getSource()==t1){String s = getstring();lg.password.setText(s+t1.getText());}
		if(e.getSource()==t2){String s = getstring();lg.password.setText(s+t2.getText());}
		if(e.getSource()==t3){String s = getstring();lg.password.setText(s+t3.getText());}
		if(e.getSource()==t4){String s = getstring();lg.password.setText(s+t4.getText());}
		if(e.getSource()==t5){String s = getstring();lg.password.setText(s+t5.getText());}
		if(e.getSource()==t6){String s = getstring();lg.password.setText(s+t6.getText());}
		if(e.getSource()==t7){String s = getstring();lg.password.setText(s+t7.getText());}
		if(e.getSource()==t8){String s = getstring();lg.password.setText(s+t8.getText());}
		if(e.getSource()==t9){String s = getstring();lg.password.setText(s+t9.getText());}
		if(e.getSource()==t10){String s = getstring();lg.password.setText(s+t10.getText());}
		if(e.getSource()==t11){String s = getstring();lg.password.setText(s+t11.getText());}
		if(e.getSource()==Thr1){String s = getstring();lg.password.setText(s+Thr1.getText());}
		if(e.getSource()==Thr2){String s = getstring();lg.password.setText(s+Thr2.getText());}
		if(e.getSource()==Thr3){String s = getstring();lg.password.setText(s+Thr3.getText());}
		if(e.getSource()==FO1){String s = getstring();lg.password.setText(s+FO1.getText());}
		if(e.getSource()==FO2){String s = getstring();lg.password.setText(s+FO2.getText());}
		if(e.getSource()==FI1){String s = getstring();lg.password.setText(s+FI1.getText());}
		if(e.getSource()==FI2){String s = getstring();lg.password.setText(s+FI2.getText());}
		/**
		 * 逐个清除字符
		 * */
		if(e.getSource()==Backspace){
			String s = getstring();
			if(s.length()>0){
			System.out.println(s);
			s = s.substring(0, s.length()-1);
			lg.password.setText(s);
			}
		}
		/**
		 * 关闭键盘
		 * */
		if(e.getSource()==FO3){
			this.setVisible(false);
		}
		System.out.println(getstring());
	}
	public void mouseReleased(MouseEvent e) {
		//鼠标按钮在组件上释放时调用�??	
	}
	/**
	 * <br>返回password的字符串
	 * <br>return superstr;
	 * */
	@SuppressWarnings("static-access")
	public String getstring(){
		superstr = String.valueOf(lg.password.getPassword());
		if(superstr.equals("")||superstr.equals(null)){
			superstr = "";
		}
		return superstr;
	}
}

 

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics