-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0, 6
-
b15
-
generic
-
generic
-
Verified
Name: sg39081 Date: 07/07/99
The Swing LineBorder doesn't draw rounded borders properly.
The following change fixes the problem:
In javax.swing.border.LineBorder.java in paintBorder(), replace:
for(i = 0; i < thickness; i++) {
if(!roundedCorners)
g.drawRect(x+i, y+i, width-i-i-1, height-i-i-1);
else
g.drawRoundRect(x+i, y+i, width-i-i-1, height-i-i-1, thickness, thickness);
}
with
if(!roundedCorners) {
for(i = 0; i < thickness; i++) {
g.drawRect(x+i, y+i, width-i-i-1, height-i-i-1);
}
} else {
g.fillRoundRect(x,y,width,thickness,thickness,thickness);
g.fillRoundRect(x,y+height-thickness,width,thickness,thickness,thickness);
g.fillRoundRect(x,y,thickness,height,thickness,thickness);
g.fillRoundRect(x+width-thickness,y,thickness,height,thickness,thickness);
}
(Review ID: 55026)
======================================================================
Name: apC97674 Date: 11/04/99
----------------Test------------------------------
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
public class bug4252164 extends JFrame {
public static void main(String[] args) {
JFrame jf = new JFrame("Focus Test");
jf.getContentPane().setLayout(new FlowLayout());
LineBorder brdr = new LineBorder(Color.blue, 7, true);
JButton bt = new JButton("Do Nothing");
bt.setBorder(brdr);
jf.getContentPane().add(bt);
jf.setSize(200,200);
jf.setVisible(true);
}
}
-------------------------------------------------------
###@###.###
======================================================================
The Swing LineBorder doesn't draw rounded borders properly.
The following change fixes the problem:
In javax.swing.border.LineBorder.java in paintBorder(), replace:
for(i = 0; i < thickness; i++) {
if(!roundedCorners)
g.drawRect(x+i, y+i, width-i-i-1, height-i-i-1);
else
g.drawRoundRect(x+i, y+i, width-i-i-1, height-i-i-1, thickness, thickness);
}
with
if(!roundedCorners) {
for(i = 0; i < thickness; i++) {
g.drawRect(x+i, y+i, width-i-i-1, height-i-i-1);
}
} else {
g.fillRoundRect(x,y,width,thickness,thickness,thickness);
g.fillRoundRect(x,y+height-thickness,width,thickness,thickness,thickness);
g.fillRoundRect(x,y,thickness,height,thickness,thickness);
g.fillRoundRect(x+width-thickness,y,thickness,height,thickness,thickness);
}
(Review ID: 55026)
======================================================================
Name: apC97674 Date: 11/04/99
----------------Test------------------------------
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
public class bug4252164 extends JFrame {
public static void main(String[] args) {
JFrame jf = new JFrame("Focus Test");
jf.getContentPane().setLayout(new FlowLayout());
LineBorder brdr = new LineBorder(Color.blue, 7, true);
JButton bt = new JButton("Do Nothing");
bt.setBorder(brdr);
jf.getContentPane().add(bt);
jf.setSize(200,200);
jf.setVisible(true);
}
}
-------------------------------------------------------
###@###.###
======================================================================
- relates to
-
JDK-6540251 RoundRectangle is not symmetric without antialiasing
- Open
-
JDK-8041917 unexcepted behavior of LineBorder while using Boolean variable true
- Resolved
-
JDK-6718964 Swing border tests should be open source
- Closed