- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create Vertical progress bar occupying the entire frame in Java
For this, create a vertical progress bar −
JProgressBar progressBar = new JProgressBar(JProgressBar.VERTICAL); progressBar.setEnabled(true);
Also, set the bounds −
progressBar.setBounds(70, 50, 120, 30);
The following is an example to create vertical progress bar occupying the entire frame −
Example
package my; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JProgressBar; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar progressBar = new JProgressBar(JProgressBar.VERTICAL); progressBar.setEnabled(true); progressBar.setBounds(70, 50, 120, 30); progressBar.setBackground(Color.orange); progressBar.setForeground(Color.white); progressBar.setStringPainted(true); progressBar.setString("1000"); progressBar.setValue(20); frame.setLayout(new BorderLayout()); frame.add(progressBar, BorderLayout.CENTER); frame.setSize(600, 400); frame.setVisible(true); } }
Output
Advertisements