本文整理汇总了Java中javax.swing.JProgressBar.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar.setValue方法的具体用法?Java JProgressBar.setValue怎么用?Java JProgressBar.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JProgressBar
的用法示例。
在下文中一共展示了JProgressBar.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showUpgradeDialog
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private static boolean showUpgradeDialog (final File source, String note) {
Util.setDefaultLookAndFeel();
JPanel panel = new JPanel(new BorderLayout());
panel.add(new AutoUpgradePanel (source.getAbsolutePath (), note), BorderLayout.CENTER);
JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
panel.add(progressBar, BorderLayout.SOUTH);
progressBar.setVisible(false);
JButton bYES = new JButton("Yes");
bYES.setMnemonic(KeyEvent.VK_Y);
JButton bNO = new JButton("No");
bNO.setMnemonic(KeyEvent.VK_N);
JButton[] options = new JButton[] {bYES, bNO};
JOptionPane p = new JOptionPane (panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, bYES);
JDialog d = Util.createJOptionProgressDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Confirmation_Title"), source, progressBar);
d.setVisible (true);
return new Integer (JOptionPane.YES_OPTION).equals (p.getValue ());
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: createWholeProgress
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createWholeProgress(int total)
{
whole = new JProgressBar(0, total);
whole.setValue(0);
whole.setStringPainted(true);
whole.setForeground(new Color(153, 153, 204));
whole.setBackground(Color.white);
return whole;
}
示例7: createCurrentProgress
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createCurrentProgress()
{
current = new JProgressBar(0, 0);
current.setValue(0);
current.setStringPainted(true);
current.setForeground(new Color(153, 153, 204));
current.setBackground(Color.white);
return current;
}
示例8: saveSEGY
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private void saveSEGY(OutputStream out) throws IOException {
if(image==null) throw new IOException("no image loaded");
String mcsPath = PathUtil.getPath("PORTALS/MULTI_CHANNEL_PATH",
MapApp.BASE_URL+"/data/portals/mcs/");
URL url = URLFactory.url( mcsPath + line.getCruiseID().trim() + "/segy/" +
line.getCruiseID().trim() +"-"+
line.getID().trim() + ".segy" );
URLConnection urlCon = url.openConnection();
BufferedInputStream in = new BufferedInputStream(urlCon.getInputStream());
int length = urlCon.getContentLength();
// Create a JProgressBar + JDialog
JDialog d = new JDialog((Frame)null, "Saving SEGY");
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
d.setLocationRelativeTo(null);
JProgressBar pb = new JProgressBar(0,length);
p.add(new JLabel("Saving " + (length / 1000000) + "mb segy file"), BorderLayout.NORTH);
p.add(pb);
d.getContentPane().add(p);
d.pack();
d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
d.setVisible(true);
byte[] b = new byte[16384];
int read = in.read(b);
while (read != -1) {
out.write(b, 0, read);
pb.setValue(pb.getValue() + read);
pb.repaint();
read = in.read(b);
}
out.flush();
in.close();
d.dispose();
}
示例9: copyFiles
import javax.swing.JProgressBar; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void copyFiles(final DefaultListModel fileModel, final JTextField txt, JProgressBar bar, Logger log) {
bar.setMinimum(0);
bar.setMaximum(fileModel.size() - 1);
for(int i = 0;i<fileModel.size(); i++) {
log.Info("COPYING: " + fileModel.getElementAt(i));
File f = new File(fileModel.getElementAt(i).toString());
try {
if(!System.getProperty("os.name").equals("Linux"))
InstallBuilderWindow.content += "Files\\" + Utils.indexOf(fileModel.getElementAt(i).toString(), '\\') + "\n";
else
InstallBuilderWindow.content += "Files/" + Utils.indexOf(fileModel.getElementAt(i).toString(), '/') + "\n";
if(!System.getProperty("os.name").equals("Linux"))
FileUtils.copyFile(f, new File(System.getProperty("user.dir") + "\\" + txt.getText() + "\\" + "Files\\" +
Utils.indexOf(fileModel.getElementAt(i).toString(), '\\')));
else
FileUtils.copyFile(f, new File(System.getProperty("user.dir") + "/" + txt.getText() + "/Files/" +
Utils.indexOf(fileModel.getElementAt(i).toString(), '/')));
} catch (IOException e) {
e.printStackTrace();
log.Error("Could not copy file\n" + e);
}
bar.setValue(i);
}
InstallBuilderWindow.content += "## FILES END ##\n\n## DIRS ##\n";
}
示例10: copyDir
import javax.swing.JProgressBar; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void copyDir(final DefaultListModel dirModel, final JTextField txt, JProgressBar bar, Logger log) {
bar.setValue(0);
bar.setMinimum(0);
bar.setMaximum(dirModel.size() - 1);
if(dirModel.size() != 0) {
for(int i = 0;i<dirModel.size(); i++) {
log.Info("COPYING: <DIR> " + dirModel.getElementAt(i));
File f = new File(dirModel.getElementAt(i).toString());
try {
if(!System.getProperty("os.name").equals("Linux"))
InstallBuilderWindow.content += "Files\\" + Utils.indexOf(dirModel.getElementAt(i).toString(), '\\') + "\n";
else
InstallBuilderWindow.content += "Files/" + Utils.indexOf(dirModel.getElementAt(i).toString(), '/') + "\n";
if(!System.getProperty("os.name").equals("Linux"))
FileUtils.copyDirectory(f, new File(System.getProperty("user.dir") + "/" + txt.getText() + "/" + "/Files/" +
Utils.indexOf(dirModel.getElementAt(i).toString(), '\\')));
else
FileUtils.copyDirectory(f, new File(System.getProperty("user.dir") + "/" + txt.getText() + "/Files/" +
Utils.indexOf(dirModel.getElementAt(i).toString(), '/')));
} catch (IOException e) {
e.printStackTrace();
log.Error("Could not copy directory\n" + e);
}
bar.setValue(i);
}
InstallBuilderWindow.content += "## DIRS END ##\n";
}else {
InstallBuilderWindow.content += "\n## DIRS END ##\n";
}
}
示例11: SearchingProgressDialog
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Create the dialog.
*/
public SearchingProgressDialog() {
setTitle("Doing web search");
setBounds(100, 100, 394, 124);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
handler = new SearchingProgressHandler() {
@Override
public boolean onStart() {
lblStatus.setText("Status: Search started. Waiting request to response...");
pb.setIndeterminate(false);
return true;
}
@Override
public boolean onPause() {
return true;
}
@Override
public boolean onLoopStart() {
return true;
}
@Override
public boolean onLoopEnd() {
lblStatus.setText("Status: Relieving result. Completed: " + this.getCompletedPages() + "/" + this.getTotalPages() + " Total result: " + this.getBeatmapIndexed());
pb.setValue((int) ((float) this.getCompletedPages() / this.getTotalPages() * 100));
return true;
}
@Override
public boolean onError() {
lblStatus.setText("Status: Errored!");
lblStatus.setForeground(Color.RED);
JOptionPane.showMessageDialog(SearchingProgressDialog.this, "Error occurred! Please check error dumps under \"osumer2 -> View Dumps\"", "Error", JOptionPane.ERROR_MESSAGE);
dispose();
return false;
}
@Override
public boolean onComplete() {
lblStatus.setText("Status: Completed. Total result: " + this.getBeatmapIndexed());
return true;
}
};
lblStatus = new JLabel("Status: Waiting to start...");
lblStatus.setFont(new Font("Tahoma", Font.PLAIN, 12));
pb = new JProgressBar();
pb.setIndeterminate(true);
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(pb, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
.addComponent(lblStatus, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE))
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblStatus)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(pb, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addContainerGap(43, Short.MAX_VALUE))
);
getContentPane().setLayout(groupLayout);
}
示例12: ProgressDialog
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* @param parentFrame The parent frame.
* @param title The dialog title.
* @param modal True if you want a modal dialog.
*/
private ProgressDialog(Frame parentFrame, String title) {
//----------------------- modal
super(parentFrame, title, true);
setLocationRelativeTo(parentFrame);
getOkButton().setVisible(false);
JPanel mainPanel = new JPanel(new GridBagLayout());
progressBar = new JProgressBar();
label = new JLabel(resourceBundle.getMessage(Tags.PROGRESS_DIALOG_LABEL));
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setSize(300, 100);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.gridwidth = 1;
gbc1.gridheight = 1;
gbc1.weightx = 1;
gbc1.weighty = 1;
gbc1.fill = GridBagConstraints.BOTH;
gbc1.anchor = GridBagConstraints.CENTER;
gbc1.ipadx = 10;
gbc1.ipady = 10;
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 1;
gbc2.gridwidth = 1;
gbc2.gridheight = 1;
gbc2.weightx = 1;
gbc2.weighty = 1;
gbc2.fill = GridBagConstraints.BOTH;
gbc2.anchor = GridBagConstraints.CENTER;
gbc2.ipadx = 10;
gbc2.ipady = 10;
mainPanel.add(label, gbc1);
mainPanel.add(progressBar, gbc2);
getContentPane().add(mainPanel, BorderLayout.CENTER);
pack();
setResizable(true);
scheduleStart();
}
示例13: downloadFully
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public static void downloadFully(URL url, File target, JProgressBar progressBar) throws IOException {
// We don't use the settings here explicitly, since HttpRequests picks up the network settings from studio directly.
try {
URLConnection connection = url.openConnection();
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection).setInstanceFollowRedirects(true);
((HttpsURLConnection) connection).setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.3.1)");
((HttpsURLConnection) connection).setRequestProperty("Accept-Charset", "UTF-8");
((HttpsURLConnection) connection).setDoOutput(true);
((HttpsURLConnection) connection).setDoInput(true);
}
connection.setConnectTimeout(3000);
connection.connect();
int contentLength = connection.getContentLength();
if (contentLength < 1) {
throw new FileNotFoundException();
}
if (progressBar != null) {
progressBar.setMinimum(0);
progressBar.setMaximum(contentLength);
}
OutputStream dest = new FileOutputStream(target);
InputStream in = connection.getInputStream();
int count;
int done = 0;
byte data[] = new byte[BUFFER_SIZE];
while ((count = in.read(data, 0, BUFFER_SIZE)) != -1) {
done += count;
if (progressBar != null) {
progressBar.setValue(done);
}
dest.write(data, 0, count);
}
dest.close();
in.close();
} finally {
if (target.length() == 0) {
try {
target.delete();
} catch (Exception e) {
}
}
}
}
示例14: KeyGenPane
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public KeyGenPane(User user)
{
this.name = user.getUser();
this.mail = user.getMail();
this.pass = user.getPassword();
bgTask = new BackgroundTask();
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progressBar.setMaximum(100);
progressBar.setMinimum(0);
progressBar.setValue(1);
JLabel taskLabel = new JLabel(
"<html>Bitte haben Sie einen Augenblick Geduld. <br>Die Schlüssel werden generiert.</html>");
button = new JButton("Start");
button.setActionCommand("weiter");
button.addActionListener(new ActionHandler());
button.setEnabled(true);
JButton btnNewButton = new JButton("abbrechen");
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(btnNewButton)
.addPreferredGap(ComponentPlacement.RELATED, 236, Short.MAX_VALUE).addComponent(button))
.addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(taskLabel,
GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE))
.addGroup(groupLayout.createSequentialGroup().addGap(67).addComponent(progressBar,
GroupLayout.PREFERRED_SIZE, 317, GroupLayout.PREFERRED_SIZE)))
.addContainerGap()));
groupLayout
.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(
groupLayout.createSequentialGroup().addGap(63).addComponent(taskLabel)
.addPreferredGap(ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
.addComponent(progressBar, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(57)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(button).addComponent(btnNewButton))
.addContainerGap()));
setLayout(groupLayout);
}
示例15: initComponents
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Inicia los componentes del panel del Score
*/
public void initComponents(){
int extra = 30;
//FUENTE
StarJedi = this.cargarFuente("../Starjedi.ttf");
/**
* TODO TIEMPO
*/
iconTiempo = new JLabel("tiempo");
iconTiempo.setBounds(40, 10+extra, 200, 50);
iconTiempo.setForeground(Color.yellow);
iconTiempo.setFont(StarJedi);
intTiempo = 0;
tiempo = new JLabel(String.valueOf(intTiempo));
tiempo.setBounds(82, 80+extra, 100, 30);
tiempo.setForeground(Color.yellow);
tiempo.setFont(StarJedi.deriveFont(1, 22f));
/**
* TODO SCORE
*/
iconScore = new JLabel("score");
iconScore.setBounds(45, 130+extra, 200, 50);
iconScore.setForeground(Color.yellow);
iconScore.setFont(StarJedi);
intScore = 0;
score = new JLabel(String.valueOf(intScore));
score.setForeground(Color.yellow);
score.setFont(StarJedi.deriveFont(1, 22f));
score.setBounds(90, 200+extra, 100, 30);
/**
* TODO COMBUSTIBLE
*/
iconFuel = new JLabel();
iconFuel.setBounds(10, 250+extra, 200, 50);
iconFuel.setForeground(Color.yellow);
iconFuel.setFont(StarJedi.deriveFont(1, 22f));
iconFuel.setText("Combustible");
fuel = new JProgressBar(0);
fuel.setBounds(25, 325+extra, 150, 30);
fuel.setValue(100);
fuel.setBackground(Color.BLACK);
/**
* TODO VIDAS
*/
iconLives = new JLabel();
iconLives.setBounds(43, 380+extra, 200, 50);
iconLives.setForeground(Color.yellow);
iconLives.setFont(StarJedi);
iconLives.setText("vidas");
intLives = 3;
lives = new JLabel(String.valueOf(intLives));
lives.setForeground(Color.yellow);
lives.setFont(StarJedi.deriveFont(1, 22f));
lives.setBounds(90, 450+extra, 100, 30);
super.add(iconTiempo, 0);
super.add(tiempo, 0);
super.add(iconScore, 0);
super.add(score, 0);
super.add(iconFuel, 0);
super.add(fuel, 0);
super.add(iconLives, 0);
super.add(lives, 0);
}