-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta2
-
x86
-
windows_nt
Name: krT82822 Date: 12/14/98
Original user synopsis: "The text in a horizontal progressbar is not placed in the (vertical) middle"
When using a horizontal JProgressBar with
setStringPainted(true), the string is not
painted in the (vertical) midle of the progress
bar.
This becomes a visible problem when the height
of the progressbar is reduced below the
preferred size.
Example program:
import java.awt.*;
import com.sun.java.swing.*;
public class pbar {
public static void main(String[] args) {
new pbar();
}
public pbar() {
JFrame frame = new JFrame();
frame.setSize(new Dimension(300, 200));
JProgressBar bar = new JProgressBar(0, 2);
bar.setValue(1);
bar.setStringPainted(true);
frame.getContentPane().add(bar);
frame.setVisible(true);
}
}
The comment in the BasicProgressBarUI.java source
hints that the text should be draw in exact
middle:
/**
* Designate the place where the progress string will be drawn.
* This implementation places it at the center of the progress
* bar (in both x and y). Override this if you want to right,
* left, top, or bottom align the progress string or if you need
* to nudge it around for any reason.
*/
protected Point getStringPlacement(...)
(Review ID: 39321)
======================================================================