本文整理汇总了Java中javax.swing.JProgressBar.setMinimum方法的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar.setMinimum方法的具体用法?Java JProgressBar.setMinimum怎么用?Java JProgressBar.setMinimum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JProgressBar
的用法示例。
在下文中一共展示了JProgressBar.setMinimum方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: StatusDialog
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public StatusDialog()
{
super(new MigLayout("fill", "fill", "fill"), true);
bar = new JProgressBar();
bar.setMinimum(0);
bar.setMaximum(100);
status = new JLabel("status here");
mainPanel.add(status, "wmin 300, wrap");
mainPanel.add(bar, "");
buttonPanel.remove(ok);
cancel.setText("Close");
}
示例4: 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";
}
示例5: 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";
}
}
示例6: StatusBar
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public StatusBar() {
super();
this.setBackground(Color.WHITE);
terminateTask = new JButton("Stop");
label = new JLabel();
label1 = new JLabel("Status ");
progressBar = new JProgressBar();
progressBar.setMinimum(50);
progressBar.setMaximum(100);
add(label1);
add(progressBar);
add(label);
add(terminateTask);
setMessage("Ready");
terminateTask.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(currentTask == null)
return;
currentTask.cancel(true);
setMessage("Task canceled");
terminateTask.setEnabled(false);
}
});
}
示例7: StatusBar
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public StatusBar() {
super();
this.setBackground(Color.WHITE);
terminateTask = new JButton("Stop");
label = new JLabel();
label1 = new JLabel("Status ");
progressBar = new JProgressBar();
progressBar.setMinimum(50);
progressBar.setMaximum(100);
add(label1);
add(progressBar);
add(label);
add(terminateTask);
setMessage("Ready");
terminateTask.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (layoutController == null /* || currentTask == null */)
return;
// currentTask.cancel(true);
if (layoutController.canStop())
layoutController.stopLayout();
setMessage("Task canceled");
terminateTask.setEnabled(false);
}
});
}
示例8: ProgressBarCellRenderer
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public ProgressBarCellRenderer() {
prog = new JProgressBar();
prog.setMinimum(0);
prog.setMaximum(100);
prog.setValue(0);
}
示例9: 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) {
}
}
}
}
示例10: 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);
}