JavaFX: Transparency and Linux

There have been a few posts regarding transparency under Linux. I have put that code together so that it can be used directly. This works for me:

[cc lang="c"]
public def osName = FX.getProperty( “javafx.os.name” );
public def IS_LINUX = osName.contains( “inux” );
public def IS_MAC = osName.contains( “mac” );
public def IS_WINDOWS = osName.contains( “indows” );
public def IS_SOLARIS = osName.contains( “olaris” );

/**
* Is the version of the running JDK at least major.minor.micro_update?
* In 1.6.0_18 macro=1,minor=6,micro=0,update=18
*/
public function jdkAtLeast( macro: Integer, minor: Integer, micro: Integer, update: Integer ): Boolean {
def runtimeVersion = java.lang.System.getProperty( “java.runtime.version” );
def pattern = java.util.regex.Pattern.compile( “^(\\d)\\.(\\d)\\.(\\d)_(\\d+)-” );
def matcher = pattern.matcher( runtimeVersion );
if ( matcher.find() ) {
def currentMacro = Integer.valueOf( matcher.group( 1 ) );
def currentMinor = Integer.valueOf( matcher.group( 2 ) );
def currentMicro = Integer.valueOf( matcher.group( 3 ) );
def currentUpdate = Integer.valueOf( matcher.group( 4 ) );
if ( currentMacro < macro or currentMinor < minor or currentMicro < micro or currentUpdate < update ) {
return false;
}
}
true
}

public function fixTransparency() {
if ( IS_LINUX and jdkAtLeast( 1, 6, 0, 14 ) ) {
java.lang.System.setProperty( “javafx.allowTransparentStage”, “true” );
}
}[/cc]


2 Responses to “JavaFX: Transparency and Linux”

  • Dhruva Ray Says:

    Hi Johannes

    There is a flickering issue with this approach when you hover on the menu/choice-box items. We spent some time to find a workaround for this. The details are at

    http://pathlesspath.blogspot.com/2010/06/how-to-get-java-fx-menus-to-work-on.html

    Regards,
    Dhruva Ray

  • Arpan Says:

    Hi Johannes,

    I tried the above code but didn’t get how to call the “fixTransparency()” method in javafx script . I am new to javafx. My example is not working yet with the transparency fixing code.Could you help me giving a complete code of this example.I am using fedora 13(64 bit) and Netbeans shipped with javafx 1.3 and my jdk is jdk-1.6 u23.

    Regards,
    Arpan

Leave a Reply