本文整理汇总了Java中javax.swing.JProgressBar.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar.setPreferredSize方法的具体用法?Java JProgressBar.setPreferredSize怎么用?Java JProgressBar.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JProgressBar
的用法示例。
在下文中一共展示了JProgressBar.setPreferredSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SplashScreen
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Constructor
*
* @throws HeadlessException
*/
public SplashScreen(final JFrame parent, final boolean showImage, final int startupStepsCount) throws HeadlessException {
super(parent, ModalityType.APPLICATION_MODAL);
final String version = Resources.getVersion();
if (showImage) {
final Image image = Resources.getImageIcon("splashscreen.jpg").getImage();
getContentPane().add(new ImageComponent(image, new String[] { "Open Visual Traceroute", version + " Leo Lewis" }), BorderLayout.CENTER);
}
_progress = new JProgressBar(1, startupStepsCount);
_progress.setIndeterminate(false);
_progress.setStringPainted(true);
_progress.setPreferredSize(new Dimension(500, _progress.getPreferredSize().height));
getContentPane().add(_progress, BorderLayout.SOUTH);
setFocusable(false);
setUndecorated(true);
pack();
setLocationRelativeTo(null);
}
示例2: FooterBar
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public FooterBar() {
setPreferredSize(new Dimension(640, 16));
setLayout(new GridLayout());
setBorder(new BevelBorder(BevelBorder.LOWERED));
Border margin = new EmptyBorder(0, 5, 0, 5);
label = new JLabel("Ready", SwingConstants.LEFT);
label.setBorder(margin);
add(label);
progress = new JProgressBar();
progress.setMaximum(6);
progress.setStringPainted(true);
progress.setPreferredSize(new Dimension(10, 16));
progress.setValue(0);
add(progress);
}
示例3: JProgressDemo
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public JProgressDemo() {
frame = new JFrame("install");
frame.setLayout(new BorderLayout());
label = new JLabel("progress",SwingConstants.CENTER);
progressbar = new JProgressBar();
progressbar.setOrientation(JProgressBar.HORIZONTAL);
progressbar.setMinimum(0);
progressbar.setMaximum(100);
progressbar.setValue(0);
//progressbar.setStringPainted(true);
progressbar.addChangeListener(this);
progressbar.setPreferredSize(new Dimension(300, 10));
progressbar.setBorderPainted(false);
progressbar.setBackground(Color.pink);
JPanel progressPane = new JPanel();
progressPane.add(progressbar);
progressPane.setPreferredSize(new Dimension(300, 10));
JPanel panel = new JPanel();
b = new JButton("install");
stop = new JButton("pause");
b.setForeground(Color.blue);
b.addActionListener(this);
stop.addActionListener(this);
panel.add(b);
panel.add(stop);
// timer=new Timer(100,this);
timer = new Timer(1000/10, this);
frame.add(panel, BorderLayout.NORTH);
frame.add(progressPane, BorderLayout.CENTER);
frame.add(label, BorderLayout.SOUTH);
// frame.pack();
frame.setBounds(100, 100, 400, 130);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
示例4: Progressbar
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public Progressbar(String title, int max) {
pbar = new JProgressBar();
pbar.setMinimum(0);
pbar.setMaximum(max);
pbar.setPreferredSize(new Dimension(500, 20));
add(pbar);
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(this);
frame.setSize(new Dimension(500, 65));
frame.setVisible(true);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
}