array(2) { ["docs"]=> array(10) { [0]=> array(10) { ["id"]=> string(3) "428" ["text"]=> string(77) "Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(8) "DonetRen" ["tagsname"]=> string(55) "Visual Studio 2017|MSDN帮助|C#程序|.NET|Help Viewer" ["tagsid"]=> string(23) "[401,402,403,"300",404]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400964" ["_id"]=> string(3) "428" } [1]=> array(10) { ["id"]=> string(3) "427" ["text"]=> string(42) "npm -v;报错 cannot find module "wrapp"" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "zzty" ["tagsname"]=> string(50) "node.js|npm|cannot find module "wrapp“|node" ["tagsid"]=> string(19) "[398,"239",399,400]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400760" ["_id"]=> string(3) "427" } [2]=> array(10) { ["id"]=> string(3) "426" ["text"]=> string(54) "说说css中pt、px、em、rem都扮演了什么角色" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(12) "zhengqiaoyin" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400640" ["_id"]=> string(3) "426" } [3]=> array(10) { ["id"]=> string(3) "425" ["text"]=> string(83) "深入学习JS执行--创建执行上下文(变量对象,作用域链,this)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "Ry-yuan" ["tagsname"]=> string(33) "Javascript|Javascript执行过程" ["tagsid"]=> string(13) "["169","191"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511399901" ["_id"]=> string(3) "425" } [4]=> array(10) { ["id"]=> string(3) "424" ["text"]=> string(30) "C# 排序技术研究与对比" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "vveiliang" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(8) ".Net Dev" ["catesid"]=> string(5) "[199]" ["createtime"]=> string(10) "1511399150" ["_id"]=> string(3) "424" } [5]=> array(10) { ["id"]=> string(3) "423" ["text"]=> string(72) "【算法】小白的算法笔记:快速排序算法的编码和优化" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "penghuwan" ["tagsname"]=> string(6) "算法" ["tagsid"]=> string(7) "["344"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511398109" ["_id"]=> string(3) "423" } [6]=> array(10) { ["id"]=> string(3) "422" ["text"]=> string(64) "JavaScript数据可视化编程学习(二)Flotr2,雷达图" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "chengxs" ["tagsname"]=> string(28) "数据可视化|前端学习" ["tagsid"]=> string(9) "[396,397]" ["catesname"]=> string(18) "前端基本知识" ["catesid"]=> string(5) "[198]" ["createtime"]=> string(10) "1511397800" ["_id"]=> string(3) "422" } [7]=> array(10) { ["id"]=> string(3) "421" ["text"]=> string(36) "C#表达式目录树(Expression)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "wwym" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(4) ".NET" ["catesid"]=> string(7) "["119"]" ["createtime"]=> string(10) "1511397474" ["_id"]=> string(3) "421" } [8]=> array(10) { ["id"]=> string(3) "420" ["text"]=> string(47) "数据结构 队列_队列实例:事件处理" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "idreamo" ["tagsname"]=> string(40) "C语言|数据结构|队列|事件处理" ["tagsid"]=> string(23) "["246","247","248",395]" ["catesname"]=> string(12) "数据结构" ["catesid"]=> string(7) "["133"]" ["createtime"]=> string(10) "1511397279" ["_id"]=> string(3) "420" } [9]=> array(10) { ["id"]=> string(3) "419" ["text"]=> string(47) "久等了,博客园官方Android客户端发布" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(3) "cmt" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511396549" ["_id"]=> string(3) "419" } } ["count"]=> int(200) } 222 JAVA JFrame 虚拟键盘 - 爱码网

a>.Source  Code:

import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.util.Vector;
import java.awt.event.*;

public class Key_Board_In extends JFrame implements KeyListener{
    public Vector<JButton> Line1_Key=new Vector<JButton>();
    public Vector<JButton> Line2_Key=new Vector<JButton>();
    public Vector<JButton> Line3_Key=new Vector<JButton>();
    public Vector<JButton> Line4_Key=new Vector<JButton>();
    public Vector<JButton> Line5_Key=new Vector<JButton>();
    public Vector<JButton> Line6_Key=new Vector<JButton>();
    
    public String []Line1_KeyValue={"Esc","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","PrtSc","NumLock"};//上
    public boolean []Line1_bool={false,false,false,false,false,false,false,true,false,false,false,false,false,true,true};
    public String []Line2_KeyValue={"  `  ","   1  ","   2  " , "   3  ","   4  ","   5  ","   6  ","   7  ","   8  ","   9  ","   0  ","  -  ","  =  ","      <---     "};
    public boolean []Line2_bool={false,false,false,false,false,false,false,false,false,false,false,false,false,false};
    public String []Line3_KeyValue={"       Tab       ","  Q  ","  W  ","  E  ","  R  ","  T  ","  Y  ","  U  ","  I  ","  O  ","  P  ","  [  ","  ]  ","  Del  "};
    public boolean []Line3_bool={true,false,false,false,false,false,false,false,false,false,false,false,false,false};
    public String []Line4_KeyValue={"    CapsLock   ","  A  ","  S  ","  D  ","  F  ","  G  ","  H  ","  J  ","  K  ","  L  ","  ;  ","  ,  ","        Enter        "};
    public boolean []Line4_bool={false,false,false,false,false,false,false,false,false,false,false,false,false};
    public String []Line5_KeyValue={"         Shift          ","   Z   ","   X   ","   C   ","   V   ","   B   ","   N   ","   M   ","   ,   ","   .   ","   /   ","        Shift        "};
    public boolean []Line5_bool={false,false,false,false,false,false,false,false,false,false,false,false};
    public String []Line6_KeyValue={"   Ctrl  ","  Fn  ","  Alt  ","                      Empty                      ","  Alt  ","   \\   ","   Home   ","   PgUP   ","   PgDn   ","  End "};
    public boolean []Line6_bool={false,false,false,false,false,false,false,false,false,false};
    
    public int InputKeyTotal=4;
    public JPanel Line1=new JPanel();
    public JPanel Line2=new JPanel();
    public JPanel Line3=new JPanel();
    public JPanel Line4=new JPanel();
    public JPanel Line5=new JPanel();
    public JPanel Line6=new JPanel();
    public JPanel AllLine=new JPanel();
    public static void main(String []args)
    {
        Key_Board_In MyKey_Board_In=new Key_Board_In();
    }
    
    public Key_Board_In()
    {
        //添加键值
        for(int n=0;n<this.Line1_KeyValue.length;n++)//第一列键盘
            this.SetButton(this.Line1_KeyValue[n], 10, 8,Line1_Key);
        
        for(int x=0;x<this.Line2_KeyValue.length;x++)//第二列键盘
            this.SetButton(this.Line2_KeyValue[x], 20, 10,Line2_Key);
        for(int x=0;x<this.Line3_KeyValue.length;x++)//第三列键盘
            this.SetButton(this.Line3_KeyValue[x], 20, 10,Line3_Key);
        for(int x=0;x<this.Line4_KeyValue.length;x++)//第四列键盘
            this.SetButton(this.Line4_KeyValue[x], 20, 10,Line4_Key);
        for(int x=0;x<this.Line5_KeyValue.length;x++)//第五列键盘
            this.SetButton(this.Line5_KeyValue[x], 20, 10,Line5_Key);
        for(int x=0;x<this.Line6_KeyValue.length;x++)//第六列键盘
            this.SetButton(this.Line6_KeyValue[x], 20, 10,Line6_Key);
        
        //添加控件到面板
        this.SetJPanel(Line1_Key,Line1);
        this.SetJPanel(Line2_Key,Line2);        
        this.SetJPanel(Line3_Key,Line3);    
        this.SetJPanel(Line4_Key,Line4);
        this.SetJPanel(Line5_Key,Line5);
        this.SetJPanel(Line6_Key,Line6);
        
        //添加面板到集合面板
        AllLine.add(Line1);
        AllLine.add(Line2);
        AllLine.add(Line3);
        AllLine.add(Line4);
        AllLine.add(Line5);
        AllLine.add(Line6);
        
        //窗体设置
        this.add(AllLine);
        this.setUndecorated(true);
        this.setSize(880,290);
        this.setResizable(false);
        this.setLocation(1920/2, 1080/2);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        
        this.draw();
    }
    
    public void paint(Graphics g)
    {
        super.paint(g);
    }
    
    private void draw()//增加
    {
        
        for(int i=0;i< Line1_Key.size();i++)
        {
            Line1_Key.get(i).addKeyListener(this);
        }
        
        for(int i=0;i< Line2_Key.size();i++)
        {
            Line2_Key.get(i).addKeyListener(this);
        }
        
        for(int i=0;i< Line3_Key.size();i++)
        {
            Line3_Key.get(i).addKeyListener(this);
        }
        
        for(int i=0;i< Line4_Key.size();i++)
        {
            Line4_Key.get(i).addKeyListener(this);
        }
        
        for(int i=0;i< Line5_Key.size();i++)
        {
            Line5_Key.get(i).addKeyListener(this);
        }
        
        for(int i=0;i< Line6_Key.size();i++)
        {
            Line6_Key.get(i).addKeyListener(this);
        }
    }
    public void SetButton(String KeyStr,int x,int y,Vector<JButton>LineKey)//添加每行键值
    {
        JButton Temp=new JButton(KeyStr);
        Temp.setSize(x,y);
        LineKey.add(Temp);
    }
    
    public void SetJPanel(Vector<JButton> LineKey,JPanel LineNumber)//将每行键值添加到板
    {
        for(int i=0;i<LineKey.size();i++)
            LineNumber.add(LineKey.get(i));
    }
    

    @Override
    public void keyPressed(KeyEvent e)
    {
        System.out.println(e.getKeyCode());
        //System.out.println(this.InputKeyTotal);
        int []KeyValue1={27,112,113,114,115,116,117,118,119,120,121,122,123,0,144};
        int []KeyValue2={192,49,50,51,52,53,54,55,56,57,48,45,61,8};
        int []KeyValue3={9,81,87,69,82,84,89,85,73,79,80,91,93,127};
        int []KeyValue4={20,65,83,68,70,71,72,74,75,76,59,222,10};
        int []KeyValue5={16,90,88,67,86,66,78,77,44,46,47,16};
        int []KeyValue6={17,524,18,32,18,92,38,37,39,40};
        for(int i=0;i<Line1_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue1[i])
            {
                if(Line1_bool[i]==false)this.InputKeyTotal++;
                Line1_Key.get(i).setBackground(Color.green);
                Line1_bool[i]=true;
            }
            Line1_Key.get(7).setBackground(Color.green);
            Line1_Key.get(Line1_Key.size()-1).setBackground(Color.green);
            Line1_Key.get(Line1_Key.size()-2).setBackground(Color.green);
            Line3_Key.get(0).setBackground(Color.green);
        }
        
        for(int i=0;i<Line2_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue2[i])
            {
                if(Line2_bool[i]==false)this.InputKeyTotal++;
                Line2_Key.get(i).setBackground(Color.green);
                Line2_bool[i]=true;
            }    
        }
        
        for(int i=1;i<Line3_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue3[i])
            {
                if(Line3_bool[i]==false)this.InputKeyTotal++;
                Line3_Key.get(i).setBackground(Color.green);
                Line3_bool[i]=true;
            }
        }
        
        for(int i=0;i<Line4_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue4[i])
            {
                if(Line4_bool[i]==false)this.InputKeyTotal++;
                Line4_Key.get(i).setBackground(Color.green);
                Line4_bool[i]=true;
            }            
        }
        
        for(int i=0;i<Line5_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue5[i])
            {
                if(Line5_bool[i]==false)this.InputKeyTotal++;
                Line5_Key.get(i).setBackground(Color.green);
                Line5_bool[i]=true;
            }            
        }
        
        for(int i=0;i<Line6_Key.size();i++)
        {
            if(e.getKeyCode()==KeyValue6[i])
            {
                if(Line6_bool[i]==false)this.InputKeyTotal++;
                Line6_Key.get(i).setBackground(Color.green);
                Line6_bool[i]=true;
            }                    
        }
        if(this.InputKeyTotal==78)System.exit(0);
    }
    
    @Override
    public void keyReleased(KeyEvent e)
    {
    }
    
    @Override
    public void keyTyped(KeyEvent e){}
}

 

JAVA JFrame 虚拟键盘

相关文章: