segmentedTextured JButtons render poorly on OpenJDK 7

Steve McLeod steve.mcleod at gmail.com
Wed May 2 06:51:52 PDT 2012


(I originally posted to java-dev at lists.apple.com, but someone suggested this forum would be better) 

I''m using OpenJDK 1.7.0_04. I'm using the client property "segmentedTextured" on some buttons. The top and bottom of the buttons are not rendered. Here's the simplest reproduction code I've been able to create.

import javax.swing.*;
import java.awt.*;

public class SegmentedTexturedButtonTest {

    public static void main(String[] args) {
        Image iconView = Toolkit.getDefaultToolkit().getImage("NSImage://NSIconViewTemplate");
        Image  listView = Toolkit.getDefaultToolkit().getImage("NSImage://NSListViewTemplate");

        JToggleButton leftButton = new JToggleButton("View", new ImageIcon(iconView));
        leftButton.putClientProperty("JButton.buttonType", "segmentedTextured");
        leftButton.putClientProperty("JButton.segmentPosition", "first");
        leftButton.setFocusable(false);

        JToggleButton rightButton = new JToggleButton("List", new ImageIcon(listView));
        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("Test");
        frame.setContentPane(contentPane);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}



The same code renders properly on Apple's Java 6. I observe the problem on OS X 10.7 and OS X 10.8.

A secondary problem (or perhaps non-problem) is that the code above results in a window with smaller width being shown with OpenJDK 7

Screenshots demonstrating the problem:

With Java 6: http://pokercopilot.com/stuff/java6_segmented_texture_buttons.png

With OpenJDK 7: http://pokercopilot.com/stuff/java7_segmented_texture_buttons.png

Regards, 

Steve  
---------------------------------------------------
Steve McLeod
Founder, Poker Copilot
http://www.pokercopilot.com




More information about the macosx-port-dev mailing list