JProgressBar如何控制程序的流程?谢谢 学习。他好象不能控制程序的运行吧,应该是模拟程序的运行进度,也不是真的就那样。只是在程序的线程运行过程中,去访问JProgressBar,更新他的值(大部分用颜色填充),来给你一种进度的感觉。继续学习。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是我看到了的一则代码,我用后觉得有控制但是不是很好,大家看看,给些意见! m_counter = 0; progress1.setValue(m_counter); jPanel11.remove(jScrollPane4); jPanel11.add(panel1, BorderLayout.CENTER); jTabbedPane2.setVisible(true); jTabbedPane2.paintAll(jTabbedPane2.getGraphics()); UpdateThread update = new UpdateThread(); update.start(); MyNode node = new MyNode(Schema, BO_name, "bo", level); MyModel model = new MyModel(node); JTree jTree2 = new JTree(model); jScrollPane4.getViewport().add(jTree2, null); if (!update.isInterrupted()) { update.interrupt(); update.stop(); } while (m_counter < m_max) { progress1.setValue(m_counter); jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(), progress1.getWidth(), panel1.getHeight() / 7); m_counter = m_counter + 2; try { Thread.sleep(50); } catch (Exception ex) { } 线程 class UpdateThread extends Thread { Runnable runme; public UpdateThread() { } public void run() { m_counter = m_min; try { while (m_counter <= m_max) { progress1.setValue(m_counter); jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(), progress1.getWidth(), panel1.getHeight() / 7); m_counter = m_counter + 2; try { Thread.sleep(500); } catch (Exception ex) { } } } catch (Exception e) { while (m_counter < m_max) { progress1.setValue(m_counter); jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(), progress1.getWidth(), panel1.getHeight() / 7); m_counter = m_counter + 2; try { Thread.sleep(50); } catch (Exception ex) { } } return; } } } 你最大值m_max是怎么得到的? 刚才,发作地方了。抱歉!我就是因为m_max无法得到,所以没办法控制的。各位有什么想法?谢谢 java基础小问题 老题了,一直不理解:String s = "a" + "b" + "c" + "d" + "e";一共创建了几个对象??? SOS~~关于applet数字签名的问题 有一圈数字,求出其连续4个数字和的最大值??? 请高手说说数组和集合的特点和区别 请教两个问题。谢谢:) 求救~关于install sheild 请问两个字符串数组怎样相加? String 如何转换成 java.lang.Date 为什么JTree 初始时根节点是展开的? 请教,在input框的value中加"怎么加 请问,如何替代字符串中的几个字符
我用后觉得有控制但是不是很好,大家看看,给些意见!
m_counter = 0;
progress1.setValue(m_counter);
jPanel11.remove(jScrollPane4);
jPanel11.add(panel1, BorderLayout.CENTER);
jTabbedPane2.setVisible(true);
jTabbedPane2.paintAll(jTabbedPane2.getGraphics());
UpdateThread update = new UpdateThread();
update.start();
MyNode node = new MyNode(Schema, BO_name, "bo", level);
MyModel model = new MyModel(node);
JTree jTree2 = new JTree(model);
jScrollPane4.getViewport().add(jTree2, null);
if (!update.isInterrupted()) {
update.interrupt();
update.stop();
}
while (m_counter < m_max) {
progress1.setValue(m_counter);
jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
progress1.getWidth(),
panel1.getHeight() / 7);
m_counter = m_counter + 2;
try {
Thread.sleep(50);
}
catch (Exception ex) {
} 线程
class UpdateThread
extends Thread {
Runnable runme;
public UpdateThread() {
} public void run() {
m_counter = m_min;
try {
while (m_counter <= m_max) {
progress1.setValue(m_counter); jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
progress1.getWidth(),
panel1.getHeight() / 7);
m_counter = m_counter + 2;
try {
Thread.sleep(500);
}
catch (Exception ex) {
}
}
}
catch (Exception e) {
while (m_counter < m_max) {
progress1.setValue(m_counter);
jTabbedPane2.paintImmediately(progress1.getX(), progress1.getY(),
progress1.getWidth(),
panel1.getHeight() / 7);
m_counter = m_counter + 2;
try {
Thread.sleep(50);
}
catch (Exception ex) {
}
}
return;
}
}
}
你最大值m_max是怎么得到的?