Mastering Java 11
上QQ阅读APP看书,第一时间看更新

Enabling GTK3 on Linux 

GTK+, formally known as the GIMP toolbox, is a cross-platform tool used for creating graphical user interfaces. The tool consists of widgets accessible through its API. Java's enhancement ensures GTK 2 and GTK 3 are supported on Linux when developing Java applications with graphical components. The implementation supports Java apps that employ JavaFX, AWT, and Swing.

We can create Java graphical applications with JavaFX, AWT, and Swing. Here is a table summarizing those three approaches as they relate to GTK, prior to Java 9:

    
Approach           Remarks
JavaFX           
  • Uses a dynamic GTK function lookup
  • Interacts with AWT and Swing via JFXPanel
  • Uses AWT printing functionality
        

      
AWT           
  • Uses a dynamic GTK function lookup
        

      
Swing           
  • Uses a dynamic GTK function lookup
        
  

So, what changes were necessary to implement this enhancement? For JavaFX, three specific things were changed:

  • Automated testing was added for both GTK 2 and GTK 3
  • Functionality was added to dynamically load GTK 2
  • Support was added for GTK 3

For AWT and Swing, the following changes were implemented:

  • Automated testing was added for both GTK 2 and GTK 3
  • AwtRobot was migrated to GTK 3
  • FileChooserDilaog was updated for GTK 3
  • Functionality was added to dynamically load GTK 3
  • The Swing GTK LnF was modified to support GTK 3
Swing GTK LnF is short for Swing GTK look and feel.