java Swing see see/** * @(#)ProgressTest.java * * * @author 张栋芳QQ271536394 * @version 1.00 2008/3/13 */import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.JProgressBar; public class ProgressTest extends JDialog{ public JProgressBar jpb; public int Max=100; public int Min=0; public int Count=1; public JButton bStart; public ProgressTest() {
* @(#)ProgressTest.java
*
*
* @author 张栋芳QQ271536394
* @version 1.00 2008/3/13
*/import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.JProgressBar;
public class ProgressTest extends JDialog{
public JProgressBar jpb;
public int Max=100;
public int Min=0;
public int Count=1;
public JButton bStart;
public ProgressTest() {
Container con=(JPanel)this.getContentPane();
con.setLayout(null);
bStart=new JButton("开始");
bStart.setBounds(10,10,70,30);
bStart.addActionListener(new MyActionListener());
jpb=new JProgressBar();
jpb.setBounds(80,20,300,20);
jpb.setMaximum(Max);
jpb.setMinimum(Min);
jpb.setAutoscrolls(true);
jpb.setStringPainted(true);//进度字
//jpb.setValue(50);
con.add(bStart);
con.add(jpb);
this.setSize(400,300);
this.setTitle("进度条的小程序");
this.setLocationRelativeTo(this);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args){
ProgressTest test=new ProgressTest();
}
private class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
if(e.getSource().equals(bStart)){
System.out.println ("ok");
UpThread thread=new UpThread();
thread.start();
}
}
}
class UpThread extends Thread{
public UpThread(){ }
public void run(){
Count=Min;
while(Count<=Max){
Count++;
jpb.setValue(Count);
try{
if(Count<40){
this.sleep(50);
}
if(Count>=40&&Count<70){
this.sleep(200);
}
if(Count>=70){
this.sleep(50);
}
}catch(Exception ae){
ae.printStackTrace();
}
}
}
}}
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str) {
var txt, i, found;
document.getElementById("body").scrollTop=0; //控制Div的滚动条滚动到最顶端
if(str == "")
return false;
if(IE4){
txt = win.document.body.createTextRange(); for(i = 0; i <= n && (found = txt.findText(str)) != false; i++){
txt.moveStart("character", 1);
txt.moveEnd("textedit");
} if(found){
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
} else {
if (n > 0){
n = 0;
findInPage(str);
}
else
alert("没有找到匹配内容!");
}
} if(NS4){
if(!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if(n == 0)
alert("没有找到匹配内容!");
}
return false;
} //响应回车键
function input_onkeypress() {
if(event.keyCode == 13){
return findInPage(form1.REG_NAME.value);
}
}