📄 toocomprogressbar.java
字号:
package toocom.ui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.font.*;
/**
* This class represents the graphical window used to present and access the different objects of the ontology.
* It provides manipulation fonctions by using right mouse click.
*
* @author Fr閐閞ic F黵st
*/
public class TooCoMProgressBar extends JDialog implements ActionListener{
private JProgressBar progress;
private javax.swing.Timer timer;
private int percent;
public TooCoMProgressBar(MainFrame mf,String title){
super(mf,title);
this.percent = 0;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((int) screenSize.getWidth()/2 - 100, (int) screenSize.getHeight()/2);
this.getContentPane().setLayout(new BorderLayout());
this.progress = new JProgressBar(new DefaultBoundedRangeModel(0,100,0,100));
int width = (int) this.getFont().getStringBounds(title,new FontRenderContext(null,true,true)).getWidth();
this.progress.setPreferredSize(new Dimension(width,20));
this.progress.setValue(0);
//this.progress.setString("youpi");
this.progress.setStringPainted(true);
this.getContentPane().add(progress,BorderLayout.NORTH);
this.pack();
this.setVisible(true);
this.timer = new javax.swing.Timer(10,this);
this.timer.start();
}
public void actionPerformed(ActionEvent e){
if(this.percent == 100){
this.timer.stop();
this.dispose();
}
else{
this.percent ++;
this.progress.getModel().setValue(this.percent);
this.repaint();
}
}
/** Set the value of progress, between 0 and 100. Setting the value to 100 will terminate
* the progress and destroy the bar. */
public void setValue(int percent){
this.percent = percent;
this.progress.getModel().setValue(this.percent);
this.repaint();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -