United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7124513 [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
JDK-7124513 : [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar

Details
Type:
Bug
Submit Date:
2011-12-23
Status:
Resolved
Updated Date:
2013-11-29
Project Name:
JDK
Resolved Date:
2012-07-24
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Relates:
Relates:
Relates:

Sub Tasks

Description
http://java.net/jira/browse/MACOSX_PORT-764 submitted 2011/12/02 by Hendrik Schreiber
For probably more than half a decade most attractive native applications on OS X have been using the unified toolbar look available through the NSWindow style NSTexturedBackgroundWindowMask. Because the title bar of Windows (e.g. JFrame) is painted by AWT/Swing, it is very hard for developers to achieve this look.
Java 6 SE for OS X honored the property <span class=&quot;nobr&quot;><a href=&quot;http://developer.apple.com/library/mac/#technotes/tn2007/tn2196.html#APPLE_AWT_BRUSHMETALLOOK&quot;>http://developer.apple.com/library/mac/#technotes/tn2007/tn2196.html#APPLE_AWT_BRUSHMETALLOOK<sup><img class=&quot;rendericon&quot; src=&quot;/jira/images/icons/linkext7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/></sup></a></span> and essentially rendered the desired background and titlebar. Unfortunately, its implementation is apparently less than perfect (see <span class=&quot;nobr&quot;><a href=&quot;http://lists.apple.com/archives/java-dev/2011/Nov/msg00033.html&quot;>http://lists.apple.com/archives/java-dev/2011/Nov/msg00033.html<sup><img class=&quot;rendericon&quot; src=&quot;/jira/images/icons/linkext7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/></sup></a></span>).
To compete with native applications on OS X, Java applications have to be able to emulate their looks. This is impossible without the unified toolbar. The biggest obstacle to implementing a unified toolbar is the titlebar style - by default it has a thin line at the bottom. There should be a way to switch this to another style that does not have that line and can be connected seamlessly to an adjacent toolbar.
Since most Mac user's value an appealing (if not sexy) UI, for all of us who try to ship commercial software for OS X based on Java, this is a showstopper for adopting OpenJDK.
Additionally, but this is not as important, it would be nice, if there was a way to specify a style for JPanels that filled them with the system's native pattern (gray gradient for Snow Leopard, gradient with noise for Lion).

                                    

Comments
EVALUATION

Author: Mike Swingler Date: 02/Dec/11 09:53 PM
The fundamental crux of this problem is that the background must be drawn by AppKit on thread 0 (most likely into the underlying window back buffer). The means that the Java content must either evade drawing their own background, or draw with a background color that is pure transparent in a SRC instead of SRC_OVER mode, so that the underlying window texture can show through.
 
Author: Hendrik Schreiber Date: 03/Dec/11 10:27 AM
No offense, but I don't think the textured background in the content pane ever really worked all the way in Java 6.
In my (Java6) code I resorted to painting all the backgrounds myself instead of using non-opaque components to let the original background shine through. That way I could be sure things looked the way I wanted them to look.
However, it's different with the titlebar - it's simply much harder (if not impossible) to get to as a regular developer.
So a first step, to make it at all possible to have a nice looking app, would be to deal with the titlebar and ignore the content pane background issues. Or just paint the background in a plain gray that matches the bottom color of the titlebar.
                                     
2011-12-23
SUGGESTED FIX

http://cr.openjdk.java.net/~serb/7124513/webrev.01/
                                     
2012-07-04
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/jdk/rev/80c592c9458e
                                     
2012-08-14
Testcase was added in JDK-8029010
                                     
2013-11-29



Hardware and Software, Engineered to Work Together