本文整理汇总了Java中javax.swing.JProgressBar类的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar类的具体用法?Java JProgressBar怎么用?Java JProgressBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JProgressBar类属于javax.swing包,在下文中一共展示了JProgressBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomComponentIsInitialized
import javax.swing.JProgressBar; //导入依赖的package包/类
@RandomlyFails // NB-Core-Build #1176
public void testCustomComponentIsInitialized() {
Controller.defaultInstance = new TestController();
ProgressHandle handle = ProgressHandleFactory.createHandle("task 1");
// Warning, this will make the handle to work with a new Controller, not TestController.
JComponent component = ProgressHandleFactory.createProgressComponent(handle);
handle.start(15);
handle.progress(2);
waitForTimerFinish();
assertEquals(15, ((JProgressBar) component).getMaximum());
assertEquals(2, ((JProgressBar) component).getValue());
handle = ProgressHandleFactory.createHandle("task 2");
component = ProgressHandleFactory.createProgressComponent(handle);
handle.start(20);
waitForTimerFinish();
assertEquals(20, ((JProgressBar) component).getMaximum());
assertEquals(0, ((JProgressBar) component).getValue());
}
示例2: createProgressPanel
import javax.swing.JProgressBar; //导入依赖的package包/类
Dialog createProgressPanel(final String message, BoundedRangeModel model) {
Dialog dialog;
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(10, 10));
panel.setBorder(new EmptyBorder(15, 15, 15, 15));
panel.add(new JLabel(message), BorderLayout.NORTH);
final Dimension ps = panel.getPreferredSize();
ps.setSize(Math.max(ps.getWidth(), DEFAULT_WIDTH), Math.max(ps.getHeight(), DEFAULT_HEIGHT));
panel.setPreferredSize(ps);
final JProgressBar progress = new JProgressBar();
if (model == null) {
progress.setIndeterminate(true);
} else {
progress.setStringPainted(true);
progress.setModel(model);
}
panel.add(progress, BorderLayout.SOUTH);
dialog = DialogDisplayer.getDefault().createDialog(new DialogDescriptor(panel, Bundle.ReferencesBrowserController_ProgressDialogCaption(), true, new Object[] { },
DialogDescriptor.CANCEL_OPTION, DialogDescriptor.RIGHT_ALIGN,
null, null));
return dialog;
}
示例3: reset
import javax.swing.JProgressBar; //导入依赖的package包/类
public static void reset() {
add(Component.class, JavaElement.class);
add(JList.class, JListJavaElement.class);
add(JTabbedPane.class, JTabbedPaneJavaElement.class);
add(JComboBox.class, JComboBoxJavaElement.class);
add(JTable.class, JTableJavaElement.class);
add(JTableHeader.class, JTableHeaderJavaElement.class);
add(JTree.class, JTreeJavaElement.class);
add(JToggleButton.class, JToggleButtonJavaElement.class);
add(JSpinner.class, JSpinnerJavaElement.class);
add(JProgressBar.class, JProgressBarJavaElement.class);
add(JSplitPane.class, JSplitPaneJavaElement.class);
add(JTextComponent.class, JTextComponentJavaElement.class);
add(EditorContainer.class, JTreeEditingContainerJavaElement.class);
add(JEditorPane.class, JEditorPaneJavaElement.class);
add(JMenuItem.class, JMenuItemJavaElement.class);
add(JSlider.class, JSliderJavaElement.class);
add(JSpinner.class, JSpinnerJavaElement.class);
add(DefaultEditor.class, DefaultEditorJavaElement.class);
add(JColorChooser.class, JColorChooserJavaElement.class);
add(JFileChooser.class, JFileChooserJavaElement.class);
}
示例4: reset
import javax.swing.JProgressBar; //导入依赖的package包/类
public static void reset() {
entries.clear();
add(Component.class, RUnknownComponent.class);
add(Window.class, RWindow.class);
add(JTable.class, RTable.class);
add(JTableHeader.class, RTableHeader.class);
add(AbstractButton.class, RAbstractButton.class);
add(JToggleButton.class, RToggleButton.class);
add(JComboBox.class, RComboBox.class);
add(JTextComponent.class, RTextComponent.class);
add(JTree.class, RTree.class);
add(JList.class, RList.class);
add(JTabbedPane.class, RTabbedPane.class);
add(JMenuItem.class, RMenuItem.class);
add(JSlider.class, RSlider.class);
add(JProgressBar.class, RProgressBar.class);
add(JSpinner.class, RSpinner.class);
add(DefaultEditor.class, RDefaultEditor.class);
add(JColorChooser.class, RColorChooser.class);
add(JSplitPane.class, RSplitPane.class);
add(BasicSplitPaneDivider.class, RSplitPane.class);
add(JFileChooser.class, RFileChooser.class);
add(JEditorPane.class, REditorPane.class);
add(JLabel.class, RLabel.class);
add(JScrollBar.class, RIgnoreComponent.class);
}
示例5: 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);
}
示例6: updateProgressBar
import javax.swing.JProgressBar; //导入依赖的package包/类
/**
* @param bar
* @param passlen
* @param sumlen
* @param lbl
*/
public void updateProgressBar(JProgressBar bar, long passlen, long sumlen,
JLabel lbl, double passTime)
{
int percent = (int) (passlen * 100 / sumlen);
bar.setValue(percent);
if (lbl != null)
{
String msg = "正在接受文件....." + (passlen / 1024) + "kb" + " /"
+ (sumlen / 1024) + "kb" + "已接收 "+ percent + "%"
+ "\n 发射点" + (int) ((passlen / 1024) / (passTime / 1000))
+ "Kb/s";
if (passlen == sumlen)
msg = "传输完毕!";
lblProgress.setText(msg);
}
}
示例7: waitValue
import javax.swing.JProgressBar; //导入依赖的package包/类
/**
* Waits progress bar string to match {@code value} parameter.
*
* @param value a string value.
* @see Operator#waitState(ComponentChooser)
*/
public void waitValue(final String value) {
output.printLine("Wait \"" + value
+ "\" string in progressbar\n : "
+ toStringSource());
output.printGolden("Wait \"" + value
+ "\" string in progressbar");
waitState(new ComponentChooser() {
@Override
public boolean checkComponent(Component comp) {
return getComparator().equals(((JProgressBar) comp).getString(), value);
}
@Override
public String getDescription() {
return "'" + value + "' string";
}
@Override
public String toString() {
return "JProgressBarOperator.waitValue.ComponentChooser{description = " + getDescription() + '}';
}
});
}
示例8: FileSaver
import javax.swing.JProgressBar; //导入依赖的package包/类
public FileSaver(JProgressBar bar, JLabel label) {
this.bar = bar;
this.label = label;
final JPopupMenu menu = new JPopupMenu("Cancel");
final JMenuItem item = new JMenuItem("Cancel");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
setCancel(true);
}
});
menu.add(item);
this.label.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
if (SwingUtilities.isRightMouseButton(ev) && isExtracting())
menu.show(ev.getComponent(), ev.getX(), ev.getY());
}
});
}
示例9: executeTestCase
import javax.swing.JProgressBar; //导入依赖的package包/类
private static void executeTestCase(String lookAndFeelString) throws Exception{
if (tryLookAndFeel(lookAndFeelString)) {
EventQueue.invokeAndWait( new Runnable() {
@Override
public void run() {
showUI();
}
} );
EventQueue.invokeAndWait( new Runnable() {
@Override
public void run() {
disposeUI();
}
} );
Util.generateOOME();
JProgressBar progressBar = sProgressBar.get();
if ( progressBar != null ) {
throw new RuntimeException( "Progress bar (using L&F: " + lookAndFeelString + ") should have been GC-ed" );
}
}
}
示例10: showUI
import javax.swing.JProgressBar; //导入依赖的package包/类
private static void showUI(){
sFrame = new JFrame();
JProgressBar progressBar = new JProgressBar();
progressBar.setVisible(false);
progressBar.setIndeterminate(false);
progressBar.setIndeterminate(true);
progressBar.setIndeterminate(false);
progressBar.setValue(10);
progressBar.setString("Progress");
sFrame.add(progressBar);
sProgressBar = new WeakReference<>(progressBar);
sFrame.setSize(200,200);
sFrame.setVisible(true);
}
示例11: 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);
}
示例12: createUI
import javax.swing.JProgressBar; //导入依赖的package包/类
private static void createUI(final String shortenedLookAndFeelString)
throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
progressBar = new JProgressBar();
progressBar.setValue(30);
frame = new JFrame(shortenedLookAndFeelString);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(progressBar);
frame.pack();
frame.setSize(500, frame.getSize().height);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
}
});
}
示例13: NbProgressBar
import javax.swing.JProgressBar; //导入依赖的package包/类
/** Creates a new instance of NbProgressBar */
public NbProgressBar() {
super();
setOrientation(JProgressBar.HORIZONTAL);
setAlignmentX(0.5f);
setAlignmentY(0.5f);
Color fg = UIManager.getColor ("nbProgressBar.Foreground");
if (fg != null) {
setForeground(fg);
}
Color bg = UIManager.getColor ("nbProgressBar.Background");
if (bg != null) {
setBackground(bg);
}
}
示例14: createJOptionProgressDialog
import javax.swing.JProgressBar; //导入依赖的package包/类
public static JDialog createJOptionProgressDialog(JOptionPane p, String title, File source, JProgressBar bar) {
progressBar = bar;
sourceFolder = source;
Object[] options = p.getOptions();
JButton bYES = ((JButton) options[0]);
JButton bNO = ((JButton) options[1]);
OptionsListener listener = new OptionsListener(p, bYES, bNO);
bYES.addActionListener(listener);
bNO.addActionListener(listener);
return createJOptionDialog(p, title);
}
示例15: setModel
import javax.swing.JProgressBar; //导入依赖的package包/类
/**
* Maps {@code JProgressBar.setModel(BoundedRangeModel)} through queue
*/
public void setModel(final BoundedRangeModel boundedRangeModel) {
runMapping(new MapVoidAction("setModel") {
@Override
public void map() {
((JProgressBar) getSource()).setModel(boundedRangeModel);
}
});
}