segmentedTextured buttons not rendered correctly
Marco Dinacci
marco.dinacci at gmail.com
Fri May 4 02:22:36 PDT 2012
Hi,
the top and bottom borders of a JToggleButton are not correctly
rendered if the client property segmentedTextured has been set.
See this screenshot: http://goo.gl/04pfw
This code reproduces the problem:
import javax.swing.*;
import java.awt.*;
public class SegmentedTexturedTest {
public static void main(String[] args) {
JToggleButton leftButton = new JToggleButton("Left Button");
//leftButton.setMargin(new Insets(3,3,3,3)); // workaround
leftButton.putClientProperty("JButton.buttonType", "segmentedTextured");
leftButton.putClientProperty("JButton.segmentPosition", "first");
leftButton.setFocusable(false);
JToggleButton rightButton = new JToggleButton("Right Button");
//rightButton.setMargin(new Insets(3,3,3,3)); // workaround
rightButton.putClientProperty("JButton.buttonType",
"segmentedTextured");
rightButton.putClientProperty("JButton.segmentPosition", "last");
rightButton.setFocusable(false);
JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0));
contentPane.add(leftButton);
contentPane.add(rightButton);
JFrame frame = new JFrame("SegmentedTexturedTest");
frame.setContentPane(contentPane);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
The workaround (see the two commented lines above) works fine for this
simple test app but not for the more complicated layout I have in my
app as the buttons takes too much space.
Any ideas what is causing this problem ?
Thanks,
Marco
More information about the macosx-port-dev
mailing list