想必你是初学者,为了让你更好的理解看一下这个程序吧

import java.awt.BorderLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JTextField;

public class Moble extends JFrame {

// Java实现一个简单的手机面板及数字输入功能

private static final long serialVersionUID = 1L;

private JTextField txtView;

public static void main(String args[]) {

new Moble();

}

public Moble() {

setTitle("Moble");

setBounds(100, 100, 200, 300);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JPanel panel = new JPanel();

getContentPane().add(panel, BorderLayout.CENTER);

setResizable(false);

txtView = new JTextField();

panel.setLayout(null);

panel.add(txtView);

final JButton btn1 = new JButton();

btn1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("1"));

}

});

btn1.setText("1");

btn1.setBounds(0, 73, 59, 23);

panel.add(btn1);

final JButton btn2 = new JButton();

btn2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("2"));

}

});

btn2.setText("2");

btn2.setBounds(65, 73, 59, 23);

panel.add(btn2);

final JButton btn3 = new JButton();

btn3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("3"));

}

});

btn3.setText("3");

btn3.setBounds(130, 73, 59, 23);

panel.add(btn3);

final JButton btn4 = new JButton();

btn4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("4"));

}

});

btn4.setText("4");

btn4.setBounds(0, 102, 59, 23);

panel.add(btn4);

final JButton btn5 = new JButton();

btn5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("5"));

}

});

btn5.setText("5");

btn5.setBounds(65, 102, 59, 23);

panel.add(btn5);

final JButton btn6 = new JButton();

btn6.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("6"));

}

});

btn6.setText("6");

btn6.setBounds(130, 102, 59, 23);

panel.add(btn6);

final JButton btn7 = new JButton();

btn7.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("7"));

}

});

btn7.setText("7");

btn7.setBounds(0, 131, 59, 23);

panel.add(btn7);

final JButton btn8 = new JButton();

btn8.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("8"));

}

});

btn8.setText("8");

btn8.setBounds(65, 131, 59, 23);

panel.add(btn8);

final JButton btn9 = new JButton();

btn9.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("9"));

}

});

btn9.setText("9");

btn9.setBounds(130, 131, 59, 23);

panel.add(btn9);

final JButton btn0 = new JButton();

btn0.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText(txtView.getText().concat("0"));

}

});

btn0.setText("0");

btn0.setBounds(68, 160, 57, 23);

panel.add(btn0);

txtView = new JTextField();

txtView.setBounds(59, 24, 90, 21);

panel.add(txtView);

final JButton btnSend = new JButton();

btnSend.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

if (txtView.getText().indexOf("calling...") == -1) {

txtView.setText(txtView.getText().concat("calling..."));

} else {

return;

}

}

});

btnSend.setText("Send");

btnSend.setBounds(40, 189, 127, 23);

panel.add(btnSend);

final JButton btnclear = new JButton();

btnclear.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

txtView.setText("");

}

});

btnclear.setText("Clear");

btnclear.setBounds(40, 212, 127, 23);

panel.add(btnclear);

final JButton btnOff = new JButton();

btnOff.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

System.exit(0);

}

});

btnOff.setText("Exit");

btnOff.setBounds(40, 232, 127, 23);

panel.add(btnOff);

setVisible(true);

}

}

java applet鼠标点击事件_Swing 鼠标单击事件?相关推荐

  1. jQuery 绑定3种鼠标事件 click(鼠标点击),mouseover(鼠标移入),mouseout(鼠标移开)

    1 click() 说明:鼠标点击时触发click事件. 语法: $(selector).click(function1); 实例: 文本框绑定click事件. $(function(){$(&quo ...

  2. Android12 部分应用(客户大型游戏)使用鼠标点击无效,鼠标模拟触摸点击

    如标题,在某些较大的游戏应用中,会限制鼠标点击不生效,导致我们的鼠标在系统其他应用上都能使用,就是某个游戏应用无法点击.调试发现,触摸事件不受影响,那么我们可以在当前游戏应用中,点击的时候模拟一下触摸 ...

  3. python鼠标点击位置_python鼠标点击位置 Python3怎么模拟鼠标点击?

    Python3怎么模拟鼠标点击? Python3怎么模拟鼠标点击?最好简单一点的方法 import win32api,win32condef click(x,y): win32api.SetCurso ...

  4. 鼠标点击测试_鼠标键盘如何检测故障,这边教您简单的测试

    沉迷,教您简单的测试鼠标故障. 有线键盘和鼠标的检测步骤: (1)将电脑关机,拔插对应的连接线. (2)移除所有除了键盘和鼠标之外的设备,然后重启电脑. (3)重启后,观察鼠标的灯是否有亮.点击滚动锁 ...

  5. js鼠标双击的时候如何屏蔽单击事件呢

    给id ="one"的div添加双击单机事件 代码 <div id="one" style="width: 400px; height: 400 ...

  6. jbutton增加监听事件_Swing 如何进行事件监听

    步骤1:按钮监听步骤2:键盘监听步骤3:鼠标监听步骤4:适配器 示例 1 : 按钮监听 创建一个匿名类实现ActionListener接口,当按钮被点击时,actionPerformed方法就会被调用 ...

  7. php点击按钮更换图片,单击事件做个替换图片

    实例 html> 使用事件给a标签添加的单击事件(结合循环遍历给a标签添加事件,达到点击就切换的效果)2019.05.08 .box { width: 500px; height: 700px; ...

  8. 解决echart单击事件、双击事件矛盾,echart双击事件会触发单击事件的问题。echart单击或者双击实现地图穿透,展示选中地图

    最近项目实现可视化,首先加载中国或者某个省,或者某个市的地图,单击其中选中的地图,其他图表数据会重新请求并变化:双击选中的地图,当前echart地图会变成选中的地图(上面描述口水话,一句简单概括,双击 ...

  9. python tablewidget单击事件_QTableWidget右键单击事件有问题

    我能够通过继承QTableWidget来模拟右键单击事件: 头文件: #ifndef QRIGHCLICKTABLE_H #define QRIGHCLICKTABLE_H #include #inc ...

最新文章

  1. nifi将hive同步到oracle,NiFi使用总结 一 hive到hive的PutHiveStreaming processor和SelectHiveQL...
  2. matlab-罗曼诺夫斯基准则剔除粗大值
  3. java 枚举类型_java 枚举类型(翻译自Java Tutorials)
  4. 《算法导论》——矩阵乘法的Strassen算法
  5. OpenGL基础6:着色器
  6. 156.PHP多进程
  7. NMAKE 详解(整理转载)
  8. 项目整体管理:结束项目或阶段
  9. “00后”消费数据分析,一文教你撩动“00后”购物欲
  10. halcon 条形码识别(持续更新)
  11. python实现规则引擎_几种开源规则引擎(BRE)的比较 转
  12. C++ 赛码打字编程题
  13. unity 粒子系统面板参数释义
  14. 【关于vue的那些事】vue.runtime.esm.js?2b0e:619
  15. 集合多种功能的转录调控数据库:hTFtarget,介绍及使用教程
  16. 最详细的Keycloak教程:Keycloak实现手机号、验证码登陆——(一)Keycloak的下载与使用
  17. 机器博弈:非零和博弈下的叶值表剪枝
  18. 关于节日文化的HTML网页设计-----二十四节气
  19. 为何国外的人都爱用电子邮箱?注册电子邮箱有哪些好处呢
  20. CCT之CAMERA TUNNING调试学习总结

热门文章

  1. Android Canvas类介绍和Android Draw Rect 坐标图示
  2. 火狐浏览器表单不跳转_表单button的outline在firefox浏览器下的问题
  3. Mysql 在DOS窗口下的操作
  4. centos7 安装 vsftpd 过程
  5. 前端开发面试题收集(html部分)
  6. 关于MX5在Mac无法正常使用开发者模式的解决方案
  7. pb将datawindow数据导出EXCEL
  8. CLR via C# 3 读书笔记(4):第1章 CLR执行模型 — 1.4 执行程序集代码
  9. 微信小程序预览pdf功能实现
  10. Java高级开发反射手段更换对象根节点内容