[java]代码库
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JProgressBarTest
{
JFrame frame = new JFrame("测试进度条");
JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL );
JCheckBox indeterminate = new JCheckBox("不确定进度");
JCheckBox noBorder = new JCheckBox("不绘制边框");
public void init()
{
Box box = new Box(BoxLayout.Y_AXIS);
box.add(indeterminate);
box.add(noBorder);
frame.setLayout(new FlowLayout());
frame.add(box);
frame.add(bar);
bar.setMinimum(0);
bar.setMaximum(100);
bar.setStringPainted(true);
noBorder.addActionListener(event ->
bar.setBorderPainted(!noBorder.isSelected()));
indeterminate.addActionListener(event -> {
bar.setIndeterminate(indeterminate.isSelected());
bar.setStringPainted(!indeterminate.isSelected());
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
for (int i = 0 ; i <= 100 ; i++)
{
bar.setValue(i);
try
{
Thread.sleep(100);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
new JProgressBarTest().init();
}
}
by: 发表于:2018-01-04 11:23:30 顶(0) | 踩(0) 回复
??
回复评论