- 浏览: 224752 次
- 性别:
- 来自: 淄博
文章分类
- 全部博客 (666)
- java (6)
- android (9)
- 架构 (0)
- android游戏 (13)
- android系统 (14)
- c++ (14)
- 数据库 (10)
- javascript (2)
- 版本控制 (1)
- webservice (1)
- linux (5)
- uml (1)
- android多媒体部分 (16)
- java中的JNI (6)
- HTML5 (5)
- CSS3 (1)
- swing (13)
- 线程并发 (9)
- 分布式 (5)
- 云计算 (1)
- 通信协议 (4)
- xml (4)
- c# (1)
- lucene (0)
- ibatis (0)
- hibernate (3)
- struts1 (3)
- struts2 (4)
- jsf (0)
- spring (5)
- spring for android (0)
- 感悟 (2)
- jpa (1)
- android gis (1)
- jbpm (0)
- java设计模式 (8)
- java web (4)
- EXT js (0)
- node JS (2)
- python (3)
- c (17)
- weblogic (0)
- opencv (1)
最新评论
/**
* 进度条
*
* @time 3:30:01 PM
* @author retacn yue
* @Email zhenhuayue@sina.com
*/
public class Test_ProgressMonitorExample extends JPanel {
private static final long serialVersionUID = 1L;
ProgressThread1 progressThread1;
static JFrame myFrame;
/**
* 构造器
*/
public Test_ProgressMonitorExample() {
setLayout(new BorderLayout());
JPanel Panel = new JPanel();
JButton btnStart = new JButton("Start");
Panel.add(btnStart);
// 开始按钮
btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 开始加载
startRunning();
}
});
// 结束按钮
JButton btnStop = new JButton("Stop");
Panel.add(btnStop);
btnStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 停止加载
stopRunning();
}
});
add(Panel, BorderLayout.SOUTH);
}
public static void main(String[] args) {
myFrame = new JFrame("");
Test_ProgressMonitorExample example = new Test_ProgressMonitorExample();
myFrame.getContentPane().add("Center", example);
myFrame.setSize(200, 100);
myFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
myFrame.setVisible(true);
}
/**
* 开始加载
*/
public void startRunning() {
if (null == progressThread1 || progressThread1.isAlive()) {
progressThread1 = new ProgressThread1(this);
progressThread1.start();
}
}
/**
* 停止加载
*/
public void stopRunning() {
progressThread1.setStop(true);
}
}
/**
* 自定义进度线程
*/
class ProgressThread1 extends Thread {
// 操作进度的类
ProgressMonitor monitor;
boolean stopStatus = false;// 状态位
// 最大值 和最小值
int min = 0;
int max = 50;
/**
* 构造器
*/
ProgressThread1(Component parent) {
monitor = new ProgressMonitor(parent, "Progress of Thread", "Not Started", min, max);
}
/**
* 停止进度
*/
public void setStop(boolean value) {
stopStatus = value;
}
@Override
public void run() {
monitor.setNote("Started");
for (int x = min; x <= max; x++) {
if (stopStatus) {
monitor.close();
break;
} else {
monitor.setProgress(x);
monitor.setNote("" + (x * 2) + "%");
try {
sleep(100);
} catch (Exception e) {
}
}
}
}
}
发表评论
-
swing 学习笔记一(画板Panel )
2012-09-04 11:18 736/** * 画板 * * @time 3:38:10 P ... -
swing学习笔记二(画布Canvas)
2012-09-04 11:19 651/** * 画布 * @time 11:23:53 AM ... -
swing学习笔记三(菜单快捷MenuBar )
2012-09-06 22:43 702/** * 菜单快捷键 * * @time 12:40: ... -
swing学习笔记四(单选按钮JRadioButton )
2012-09-06 22:44 300/** * 单选按钮 * @time 下午10:48:14 ... -
swing学习笔记六(对话框Dialog )
2012-09-06 22:47 678/** * 对话框 * * @time 11:09:20 ... -
swing 学习笔记七(菜单MenuBar )
2012-09-06 22:49 785/** * 菜单 * * @time 10:24:50 ... -
swing 学习笔记八(列表JList )
2012-09-08 16:32 639/** * 列表 * @time 4:53:26 PM ... -
swing 学习笔记九(选项卡 JApplet是japplet的扩展)
2012-09-08 16:33 637/** * 选项卡 JApplet是japplet的扩展 ... -
swing 学习笔记十(边界面局管理BorderLayout)
2012-09-08 16:35 547/** * 边界面局管理 * * @time 2:59: ... -
swing学习笔记十一(卡片布局管理器CardLayout )
2012-09-09 10:54 638/** * 卡片布局管理器 * * @time 9:49 ... -
swing 学习笔记十二(网格布局GridLayout)
2012-09-09 10:59 519/** * 网格布局 * * @time 3:22:44 ... -
swing学习笔记十四(复选框JCheckBox )
2012-09-09 11:00 554/** * 复选框 * * @time 3:54:18 ...
相关推荐
NULL 博文链接:https://huangrongyou.iteye.com/blog/1610287
SWING进度条
NULL 博文链接:https://hw1287789687.iteye.com/blog/2003105
NULL 博文链接:https://hw1287789687.iteye.com/blog/2035039
不确定某个程序运行多久,用进度条来监测,如果进度条监测到运行结果结束了,就退出进度条,否则以一种不确定的状态等待。
Java swing 知识总结学习笔记,全面总结了在Java学习中关于Swing的相关知识。
Java Swing组件:Jlist学习笔记Java Swing组件:Jlist学习笔记
Swing读书笔记,Swing读书笔记,Swing读书笔记
NULL 博文链接:https://win2011ccc.iteye.com/blog/1489985
NULL 博文链接:https://yshjava.iteye.com/blog/1326539
java swing 笔记
java 雷电游戏 雷霆战机 swing学习.zipjava 雷电游戏 雷霆战机 swing学习.zip java 雷电游戏 雷霆战机 swing学习.zipjava 雷电游戏 雷霆战机 swing学习.zip java 雷电游戏 雷霆战机 swing学习.zipjava 雷电游戏 雷霆...
swing学习
主要介绍了Java Swing JProgressBar进度条的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
java swing 的学习资料,附带代码,下载即运行,很容易上手的一个例子哦
awt和swing学习实例,代码加注释。
实现两个不同颜色的圆形进度条
在程序风格中,函数waitdialog 封装了Java Swing GUI 类JProgressBar 以增强视觉体验,但在功能上类似于内置函数waitbar。 在面向对象的风格中,ProgressDialog 是一个类,它封装了使用 waitdialog 函数创建的...