-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0, 1.2.1
-
kestrel
-
x86, sparc
-
solaris_2.6, windows_95, windows_nt
Name: gsC80088 Date: 02/10/99
it's very simple. drawString just gives up when y is less
than a certain value, while drawLine and others keep working.
/*
* this program demonstrates that after a translation, drawString
* doesn't work with y values less than about -17 or so.
*/
import java.awt.*;
public class DrawStringBug extends Component {
private Image image;
private Graphics graphics;
public Dimension getPreferredSize() {
return(new Dimension(300,300));
}
public void setBounds(int theX, int theY, int theWidth, int theHeight) {
super.setBounds(theX,theY,theWidth,theWidth);
// prepare for double-buffering
image = createImage(theWidth,theWidth);
graphics = image.getGraphics();
graphics.setColor(getBackground());
graphics.fillRect(0,0,theWidth,theWidth);
graphics.translate(theWidth/2,theWidth/2);
}
public void prePaint() {
if (image == null) {
return;
}
graphics.setColor(Color.black);
for ( int y = 30; y > -100; y -= 5 ) {
graphics.drawString(String.valueOf(y),0,y);
graphics.drawLine(-30,y,-10,y);
}
}
public void paint(Graphics theGraphics) {
if (image != null) {
theGraphics.drawImage(image,0,0,this);
}
}
public void update(Graphics theGraphics) {
if (image != null) {
theGraphics.drawImage(image,0,0,this);
}
}
public static void main(String [] args) {
Frame f = new Frame();
DrawStringBug bug = new DrawStringBug();
f.add(bug,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
bug.prePaint();
bug.repaint();
}
}
(Review ID: 53473)
======================================================================
- duplicates
-
JDK-4174599 drawString on a translated Image fails when y<-17
-
- Closed
-