jprogressbar

How to show the CPU and disk usage in a JProgressBar?

早过忘川 提交于 2019-12-14 03:21:42
问题 I want to display the current cup usage and disk usage in two separate JProgressBar s. And also it should update second by second. How to do it using java? I am quite new to java programming, so please give me some code example. Thanks in advance. 回答1: You can use javasysmon-0.3.4.jar file to get the system related informations as CPU Usage,memory usage etc. Some of the methods are listed below and if you want something else you can explore. JavaSysMon monitor=new JavaSysMon(); //System.out

JProgressBar duplicating

笑着哭i 提交于 2019-12-13 22:08:50
问题 My JProgressBar is worked perfectly up until i set my JFrame GlassPane visible. It then randomly decides to shoot across the screen and duplicate. Here is an animated GIF displaying the bug. This happens no matter what my code is - even with an extremely basic GUI http://i.gyazo.com/bd70df610a3cad6bfff258b80f21c78a.gif This ONLY happens when i do this.getGlassPane().setVisible(true); Here is the code: public void setProgress(final int percent) { pb.setValue(percent); if (percent == 100) {

java - Progress Bar - Is it possible to use setProgess() of Progress Bar outside the doInBackground() method?

拜拜、爱过 提交于 2019-12-13 16:29:30
问题 If I had a method inside the doInBackground() that belongs to other class is it possible to set setProgess() based on changes that happen in that other method of an outside class? 回答1: You state: but when I put setProgess() inside the method of another class it tells me that I need to make that method. This has nothing to do with SwingWorker and all to do with basic Java. No class can call another classes instance (non-static) methods without doing so on a valid instance of the class. For

JProgressBar doesn't update during download

徘徊边缘 提交于 2019-12-13 15:23:44
问题 Using a swing button, I'm trying to download an html file and write it to a new html file, while doing a progress bar. When I click the button, my program seems to freeze until the download finishes, and then the progress bar is suddenly 100%. I'm not quite sure how to fix this problem as I am new to java. private void jButton2MouseReleased(java.awt.event.MouseEvent evt) { try { URL oracle = new URL("http://mywebsite.com"); URLConnection yc = oracle.openConnection(); BufferedReader in = new

Progress bar not working

若如初见. 提交于 2019-12-13 10:54:15
问题 Good Evening, i have a problem in running a progress bar, please check my code and tell me where is the problem: /** ** @author Islam */ public class Register extends javax.swing.JFrame implements Runnable { static final int MY_MINIMUM = 0; static final int MY_MAXIMUM = 100; private Pattern pattern; private Matcher matcher; private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; boolean isValidPassord = true;

Why does the second JFrame does not show components?

不问归期 提交于 2019-12-13 03:38:49
问题 I have the first JFrame and it works fine. When I push a button it is supposed to show a JProgressBar frame , but i get empty JFrame. I open it with p = new Progress("1/3"); p.setMax(2); p.setProgress(0, "Getting bytes..."); Anyone know why? EDIT: I am going to explain more detail(Because someone misunderstood and corrected my post in the wrong way) - On my main class i start the first JFrame: new Crypt(); And in the Crypt class i have registered a button ActionListener. OnClick it opens a

Overriding LookAndFeel

吃可爱长大的小学妹 提交于 2019-12-13 00:35:42
问题 Hello I am trying to change the colors of my swing progress bar in java. Initially I tried using the following code: UIManager.put("ProgressBar.selectionBackground", Color.black); UIManager.put("ProgressBar.selectionForeground", Color.white); UIManager.put("ProgressBar.background", Color.white); UIManager.put("ProgressBar.foreground", Color.RED); m_progressBar.setBackground(Color.BLACK); m_progressBar.setForeground(Color.red); But none of the commands seemed to have any effect!!! Unless I set

JProgressBar does not update within the loop

喜夏-厌秋 提交于 2019-12-12 15:56:02
问题 I am currently self-studying Java. I've been trying different things like JRadioButton s, JcomboBox es etc. Now, I'm trying to use JProgressBar s but it doesn't seem to work properly. Relevant piece of code: JProgressBar progress; JButton button; //Fields of the class progress=new JProgressBar(JProgressBar.HORIZONTAL,0,100); button=new JButton("Done"); //Done from methods progress.setValue(0); progress.setStringPainted(true); progress.setBorderPainted(true); //Also done from methods button

How to use Netbeans' indeterminate progress-bar style?

半世苍凉 提交于 2019-12-12 14:46:35
问题 I'm programming a Java app using Nimbus look & feel. Unfortunately, the appearance of indeterminate JProgressBars of Nimbus look & feel is AWFUL (see below) : On the other hand, I've noticed Netbeans with Nimbus look & feel has a different indeterminate JProgressBar style which looks much better (see below) : How can I use this style in my own application? 回答1: You can write your own Painter<JComponent> : import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.beans.*;

How to use JProgressBar

泪湿孤枕 提交于 2019-12-12 09:54:31
问题 I want to use JProgressBar and it must be loaded in one second. I don't want wait for any task to complete. Just want to fill the progress bar in one second. So I write following code. But it doesn't working. progress bar wasn't filling. I am new to Java. Please can anyone help me. public void viewBar() { progressbar.setStringPainted(true); progressbar.setValue(0); for(int i = 0; i <= 100; i++) { progressbar.setValue(i); try { Thread.sleep(10); } catch (InterruptedException ex) { JOptionPane