- Trending Categories
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 can we get the values of a JProgressBar Component and display in Console?
Let’s say we have set the following values for JProgressBar −
int min = 0; int max = 1000; progressBar = new JProgressBar(min, max);
Now, get the above values and display in the Console −
int value = progressBar.getValue(); System.out.println("Value = "+value); System.out.println("Minimum = "+progressBar.getMinimum()); System.out.println("Maximum = "+progressBar.getMaximum());
The following is an example to get the values of a progress bar component −
Example
package my; import javax.swing.*; public class SwingDemo extends JFrame { JProgressBar progressBar; int i = 0; SwingDemo() { int min = 0; int max = 1000; progressBar = new JProgressBar(min, max); int value = progressBar.getValue(); System.out.println("Value = "+value); System.out.println("Minimum = "+progressBar.getMinimum()); System.out.println("Maximum = "+progressBar.getMaximum()); 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(); } }
This will produce the following output −
The following is visible in the Console −
- Related Articles
- How can we display MySQL bit values in printable form?
- Getting HTML form values and display on console in JavaScript?
- Java Program to get text from JTextPane and display in Console
- Get number from user input and display in console with JavaScript
- How can we get only unique values of a column in MySQL result set?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- How to set all the values at once using the model in a JProgressBar with Java?
- How can we get the metadata of triggers?
- How to display a large component within a smaller display area in Java?
- How can we combine values of two or more columns of MySQL table and get that value in a single column?
- How can we display the line numbers inside a JTextArea in Java?
- How can we update values in a MySQL table?
- How can I get pyplot images to show on a console app? (Matplotlib)
- How can we update the values of a collection using LINQ in C#?

Advertisements