C
C.Steamer
Basically I have this program that runs the following code. I get the error
that you see at the bottom there. The thing is I don't get it all the time
only once and a while. I have heard that switching between indeterminent
mode and determinate mode can cause some resizing problems. I have heard of
a solution to set the String to null while in determinate and set it to the
empty string when in indeterminate mode. I tried that and it doesn't seem to
work. I might have done it wrong. I suspect that I am only running into
problems once and a while because the indeterminate bar is in the middle of
the progress bar when It exits indeterminate mode causing some problem
with the string of non indeterminate mode. I don't know forsure. Also if I
comment out the indeterminate stuff, it works fine. but I would like to be
able to use this feature. Any suggestions? Thanks
This is where I create the progress Bar
JProgressBar progressBar = new JProgressBar();
progressBar.setStringPainted(true);
This is where I use the progress bar
panel.getProgressBar().setIndeterminate(true);
int totalFiles = countNonHiddenFiles(file);
panel.getProgressBar().setIndeterminate(false);
panel.getProgressBar().setMinimum(0);
panel.getProgressBar().setValue(0);
panel.getProgressBar().setMaximum(totalFiles);
recurseDirectories(file);
This is the error I get when running the program.
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicProgressBarUI.updateSizes(Unknown Source)
at javax.swing.plaf.basic.BasicProgressBarUI.getBox(Unknown Source)
at
com.sun.java.swing.plaf.windows.WindowsProgressBarUI.paintIndeterminate(Unknown
Source)
at javax.swing.plaf.basic.BasicProgressBarUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
that you see at the bottom there. The thing is I don't get it all the time
only once and a while. I have heard that switching between indeterminent
mode and determinate mode can cause some resizing problems. I have heard of
a solution to set the String to null while in determinate and set it to the
empty string when in indeterminate mode. I tried that and it doesn't seem to
work. I might have done it wrong. I suspect that I am only running into
problems once and a while because the indeterminate bar is in the middle of
the progress bar when It exits indeterminate mode causing some problem
with the string of non indeterminate mode. I don't know forsure. Also if I
comment out the indeterminate stuff, it works fine. but I would like to be
able to use this feature. Any suggestions? Thanks
This is where I create the progress Bar
JProgressBar progressBar = new JProgressBar();
progressBar.setStringPainted(true);
This is where I use the progress bar
panel.getProgressBar().setIndeterminate(true);
int totalFiles = countNonHiddenFiles(file);
panel.getProgressBar().setIndeterminate(false);
panel.getProgressBar().setMinimum(0);
panel.getProgressBar().setValue(0);
panel.getProgressBar().setMaximum(totalFiles);
recurseDirectories(file);
This is the error I get when running the program.
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicProgressBarUI.updateSizes(Unknown Source)
at javax.swing.plaf.basic.BasicProgressBarUI.getBox(Unknown Source)
at
com.sun.java.swing.plaf.windows.WindowsProgressBarUI.paintIndeterminate(Unknown
Source)
at javax.swing.plaf.basic.BasicProgressBarUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)