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; } }
- KeyBoard.rar (94.1 KB)
- 下载次数: 449
相关推荐
需要注意的是,对于不同的设备和Android版本,软键盘的显示与隐藏可能有不同的表现,因此在实际开发中需要进行充分的测试。在处理软键盘与布局交互时,还需要考虑屏幕尺寸、设备方向等因素,以确保用户体验。 在...
测试应覆盖所有可能的按键组合,包括软键盘和硬件按键。 4. **源码分析**:提供的`ReturnKeyCode`可能是一个Java源文件,用于处理返回键(KEYCODE_ENTER)的事件。分析这个源码可以帮助我们理解如何注册监听器,...
基于JAVA的推箱子游戏设计软件程序源码+word毕业论文文档. 基于JAVA的推箱子游戏系统主要用于实现游戏推箱子功能,提供多种不同难度的关卡。本系统结构如下: (1)初始化模块: 该模块包括屏幕初始化和游戏第一关的...
源码将展示如何集成到这个框架中,包括注册输入法服务(InputMethodService),处理输入事件(InputEvent),以及显示软键盘布局。 3. **Java编程**:由于Android系统主要使用Java语言进行开发,所以源码会大量使用...
本项目“安卓Android源码——仿淘宝自定义键盘.zip”提供了实现这一功能的源代码,帮助开发者构建类似淘宝应用中的自定义软键盘。下面我们将详细探讨这个自定义键盘的实现原理和相关知识点。 1. 自定义View组件: ...
- 键盘输入:支持数字键盘或软键盘输入,验证输入合法性并更新游戏状态。 - 提示和解答:提供提示功能,例如高亮可填入数字的单元格,或者自动填充合法的数字。 6. **性能优化** - 为了保持流畅的用户体验,可能...
首先,Android系统本身提供了软键盘输入的功能,但有时系统键盘可能无法满足特定场景的需求。例如,淘宝应用中的搜索框可能只需要数字输入,或者在商品详情页可能需要用户输入特定格式的信息,这时就需要自定义键盘...
开发者需要理解InputMethodManager,以及如何处理软键盘事件和与应用之间的通信。 3. **字典与词汇库**:输入法通常包含丰富的词汇库,用于快速匹配用户输入。这部分源码可能包含了字典文件的读取和解析,以及基于...
《Java自编飞机大战——新手入门实践指南》 在编程世界中,实战项目是学习新技能的最佳途径之一。本文将围绕“Java自编飞机大战”这一主题,详细讲解如何使用Java语言开发一款简单的飞机大战游戏,这对于初学者来说...
例如,`WindowManagerService`负责管理窗口的布局和触摸事件的分发,`InputMethodManagerService`则处理软键盘的显示与隐藏。开发者可能会在这些服务的源码中找到处理触摸事件的关键逻辑。 5. 测试与调试:为了确保...
这个服务提供了软键盘、手写等不同输入方式,并通过InputConnection接口与应用进行通信。InputConnection接口允许应用发送和接收键盘事件,以及执行文本操作,如复制、粘贴等。 要监听delete键,我们需要对EditText...
- 要让用户方便地插入表情,通常需要自定义一个软键盘,包含表情面板,用户点击表情后,代码会将对应的图片或字符插入到EditText中。 - 自定义键盘可以通过创建一个InputMethodService来实现,它是一个服务,可以...
KeyboardView是Android SDK提供的一种用于显示虚拟键盘的视图,它可以用来替代系统默认的软键盘。通过自定义键盘布局,我们可以创建各种类型的键盘,如数字键盘、字母键盘等。在"安卓键盘输入相关-android自定义键盘...
- **数据解析**:JSON格式的数据解析,可能使用Gson或Jackson库来将网络响应转换为Java对象。 4. **UI组件与布局** - **RecyclerView**:用于展示微博列表,利用Adapter和ViewHolder实现高效滚动。 - **...
标签"键盘输入"进一步确认了这个项目的核心功能,即关注于如何在安卓设备上创建一个定制化的输入界面,用于替代或辅助系统默认的软键盘。 从压缩包子文件的文件名称列表来看,我们有以下三个文件: 1. **JavaApk...
自定义键盘允许应用程序提供自己的输入界面,替代系统默认的软键盘。这通常用于特定类型的输入,如数字、符号或特殊字符,或者为了提供更好的用户体验。 2. **JavaApk源码说明.txt** 这个文件可能包含了关于源码...
在安卓系统中,用户可以通过EditText组件进行文本输入,系统会自动弹出软键盘。然而,为了提供定制化的输入体验,开发者可能需要自定义键盘。这涉及到对ViewGroup、自定义View和触摸事件处理的理解。 在这个demo中...
在Android中,可以设置`InputMethodManager`的参数,或者在XML布局中设置`android:inputType="number"`来限制只能输入数字,同时隐藏软键盘。 4. 控件封装:将上述功能封装成一个可复用的组件,以便在项目其他地方...
这可能涉及到自定义软键盘布局,或者使用第三方库,如Android的`InputMethodService`。 3. **显示Emoji**:Android系统版本不同,对Emoji的支持程度也不同。旧版本可能不支持所有Unicode字符,因此需要确保应用能够...
这部分源码可以帮助我们理解如何使用Java来处理事件驱动的程序设计,如键盘监听和时间管理。同时,游戏通常会有一个用户界面,Java提供了Swing和JavaFX库来构建图形用户界面,我们可以从中学习如何创建窗口、按钮、...