dome9.java
来自「小游戏用JAVA做的」· Java 代码 · 共 38 行
JAVA
38 行
import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JProgressBar;
import javax.swing.Timer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Dome9 extends JFrame implements ActionListener
{
private JProgressBar pb = new JProgressBar(0, 100);
private Timer tr = new Timer(1000, this);
public Dome9()
{
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pb.setStringPainted(true);
tr.start();
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(pb, BorderLayout.CENTER);
this.setSize(400,300);
this.setVisible(true);
}
public static void main(String [] args)
{
new Dome9();
}
public void actionPerformed(ActionEvent e)
{
pb.setValue(pb.getValue()+1);
pb.setString("当前完成 了: "+pb.getValue()+" %");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?