-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b46
-
x86
-
windows_2000
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 2000 SP4
A DESCRIPTION OF THE PROBLEM :
Resizing JFrame with JProgressBar to zero by dragging a border cause an IllegalArgumentException exception in BasicStroke object constructor...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run an example.
drag a bottom side of the frame up to minimize it to header only.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception.
ACTUAL -
Failed to paint so some artifacts occur
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: negat
ive width
at java.awt.BasicStroke.<init>(BasicStroke.java:181)
at javax.swing.plaf.basic.BasicProgressBarUI.paintDeterminate(BasicProgr
essBarUI.java:596)
at javax.swing.plaf.metal.MetalProgressBarUI.paintDeterminate(MetalProgr
essBarUI.java:45)
at javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.ja
va:352)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.dim;
import javax.swing.*;
import java.awt.*;
public class JProgressBarTest extends JFrame
{
public JProgressBarTest()
{
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(g);
c.weighty = 1.0;
JProgressBar bar = new JProgressBar();
g.setConstraints(bar, c);
add(bar);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args)
{
Toolkit.getDefaultToolkit().setDynamicLayout(true);
new JProgressBarTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
removing "c.weighty = 1.0" helps.
*************************
in javax.swing.plaf.basic.BasicProgressBarUI.java :
protected void paintDeterminate(Graphics g, JComponent c) {
if (!(g instanceof Graphics2D)) {
return;
}
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
int cellLength = getCellLength();
int cellSpacing = getCellSpacing();
// amount of progress to draw
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(progressBar.getForeground());
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
// draw the cells
if (cellSpacing == 0 && amountFull > 0) {
// draw one big Rect because there is no space between cells
g2.setStroke(new BasicStroke((float)barRectHeight,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
...
as you can see
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
could be negative and it generates an exception calling
g2.setStroke(new BasicStroke((float)barRectHeight,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
*****************************
###@###.### 2005-03-03 17:45:43 GMT
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 2000 SP4
A DESCRIPTION OF THE PROBLEM :
Resizing JFrame with JProgressBar to zero by dragging a border cause an IllegalArgumentException exception in BasicStroke object constructor...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run an example.
drag a bottom side of the frame up to minimize it to header only.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception.
ACTUAL -
Failed to paint so some artifacts occur
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: negat
ive width
at java.awt.BasicStroke.<init>(BasicStroke.java:181)
at javax.swing.plaf.basic.BasicProgressBarUI.paintDeterminate(BasicProgr
essBarUI.java:596)
at javax.swing.plaf.metal.MetalProgressBarUI.paintDeterminate(MetalProgr
essBarUI.java:45)
at javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.ja
va:352)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:840)
at javax.swing.JComponent.paint(JComponent.java:1012)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.dim;
import javax.swing.*;
import java.awt.*;
public class JProgressBarTest extends JFrame
{
public JProgressBarTest()
{
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(g);
c.weighty = 1.0;
JProgressBar bar = new JProgressBar();
g.setConstraints(bar, c);
add(bar);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args)
{
Toolkit.getDefaultToolkit().setDynamicLayout(true);
new JProgressBarTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
removing "c.weighty = 1.0" helps.
*************************
in javax.swing.plaf.basic.BasicProgressBarUI.java :
protected void paintDeterminate(Graphics g, JComponent c) {
if (!(g instanceof Graphics2D)) {
return;
}
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
int cellLength = getCellLength();
int cellSpacing = getCellSpacing();
// amount of progress to draw
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(progressBar.getForeground());
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
// draw the cells
if (cellSpacing == 0 && amountFull > 0) {
// draw one big Rect because there is no space between cells
g2.setStroke(new BasicStroke((float)barRectHeight,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
...
as you can see
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
could be negative and it generates an exception calling
g2.setStroke(new BasicStroke((float)barRectHeight,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
*****************************
###@###.### 2005-03-03 17:45:43 GMT