 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set Bounds for JProgressBar in Java Swing
Use the setBounds() method to set Bounds for JProgressBar in Java Swing −
JProgressBar progressBar; progressBar.setBounds(70, 50, 120, 30);
The following is an example to set bounds for JProgressBar −
Example
package my; import javax.swing.*; public class SwingDemo extends JFrame {    JProgressBar progressBar;    int i = 0;    SwingDemo() {       progressBar = new JProgressBar(0, 1000);       progressBar.setBounds(70, 50, 120, 30);       progressBar.setValue(0);       progressBar.setStringPainted(true);       add(progressBar);       setSize(550, 150);       setLayout(null);    }    public void inc() {       while (i <= 1000) {          progressBar.setValue(i);          i = i + 50;          try {             Thread.sleep(100);          } catch (Exception e) {}       }    }    public static void main(String[] args) {       SwingDemo s = new SwingDemo();       s.setVisible(true);       s.inc();    } } The output displays a ProgessBar that fills completely −
Output

Advertisements
 