📄 progressbartosource.java
字号:
/**
* Email: taorundong@126.com
*
* @author taorundong
* @version 1.00 07/02/11
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class ProgressBarToSource extends JFrame implements ActionListener{
private
JProgressBar progressBar = null;
JLabel label = null;
Timer timer = null;
int sum;
int perTime;
ProgressBarToSource(){
progressBar = new JProgressBar(JProgressBar.HORIZONTAL,0,1000);
label = new JLabel();
timer = new Timer(1000,this);
sum = 0;
perTime = 1000/8;
setScreenSize();
setLabelImage();
addProgressBar();
this.setVisible(true);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
// timer.start();
}
public boolean checkSource(String name){
File sourceName = new File(name);
if(sourceName.isFile()){
return true;
}
else
return false;
}
public void addProgressBar(){
progressBar.setString("Loading");
progressBar.setVisible(true);
progressBar.setForeground(Color.green);
progressBar.setBackground(Color.white);
progressBar.setStringPainted(true);
progressBar.validate();
Container con = this.getContentPane();
con.add(progressBar,"South");
con.validate();
}
public void actionPerformed(ActionEvent e){
}
public boolean setLabelImage(){
try{
Container con = this.getContentPane();
label.setIcon(new ImageIcon("picture\\2.jpg"));
label.validate();
con.add(label,"Center");
con.validate();
return true;
}
catch(Exception e){
e.printStackTrace();
return false;
}
}
public void setScreenSize(){
Dimension screen = this.getToolkit().getScreenSize();
this.setBounds((screen.width/2-150),(screen.height/2-100),300,200);
// this.setResizable(false);
}
public static void main(String args[]){
ProgressBarToSource bar = new ProgressBarToSource();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -