{"id":3609,"date":"2015-11-23T23:16:10","date_gmt":"2015-11-23T22:16:10","guid":{"rendered":"https:\/\/blog.hani-ibrahim.de\/?p=3609"},"modified":"2020-10-07T18:28:34","modified_gmt":"2020-10-07T17:28:34","slug":"ubuntus-swing-gtk-laf","status":"publish","type":"post","link":"https:\/\/blog.hani-ibrahim.de\/en\/ubuntus-swing-gtk-laf.html","title":{"rendered":"Java&#8217;s Swing GTK LaF nice and pretty on Ubuntu"},"content":{"rendered":"<nav class=\"tinytoc tiny_toc\">\n<ul>\n<li><a href=\"#h0\">Global Menu and HUD support<\/a><\/li>\n<li><a href=\"#h1\">Better Font Rendering<\/a><\/li>\n<li><a href=\"#h2\">How to revert the changes<\/a><\/li>\n<li><a href=\"#h3\">Related Links<\/a><\/li>\n<\/ul>\n<\/nav>\n\n\r\n<body><p>In Ubuntu Java apps which use Swing\u2019s GTK Look and Feel (LaF) do not appear as native applications.<\/p>\n<p>The menus does not have borders and do not appear as app menus on the top of the screen nor provide <a href=\"https:\/\/wiki.ubuntuusers.de\/Unity\/HUD\" target=\"_blank\" rel=\"noopener noreferrer\">HUD<\/a> support. The fonts on buttons and dialog boxes are thinner and do not match to the native look and feel.<\/p>\n<p>This how-to describes step by step how you improve the GTK LaF of Java\u2019s Swing apps.<!--more--><\/p>\n<p>For Linux Mint (Cinnamon, XFCE) refer my posting\u00a0<a href=\"https:\/\/blog.hani-ibrahim.de\/swing-menus-gtk-laf.html\">Display Java\u2019s Swing menus correctly in GTK LaF<\/a> for details.<\/p>\n<h3 id=\"h0\">Global Menu and HUD support<\/h3>\n<p>For the global menu and HUD support you need to install the package \u201cAyatana\u201d. This solves the border problem as a positive side-effect. Because it is not in Ubuntu\u2019s repositories you have to get it via PPA. You have to type in the terminal:<\/p>\n<pre class=\"linux-code\"><code>sudo add-apt-repository ppa:danjaredg\/jayatana\r\nsudo apt-get update\r\nsudo apt-get install jayatana<\/code><\/pre>\n<p>Once installed, log out and log back in. If you want to perform the following steps too, you just need to log out and in at the end of the whole process.<\/p>\n<h3 id=\"h1\">Better Font Rendering<\/h3>\n<p>To improve the appearance of fonts in Java apps install the package\u00a0 \u201cInfinality\u201d from the following PPA first:<\/p>\n<pre class=\"linux-code\"><code>sudo add-apt-repository ppa:no1wantdthisname\/ppa\r\nsudo apt-get update\r\nsudo apt-get upgrade\r\nsudo apt-get install fontconfig-infinality<\/code><\/pre>\n<p>After install a patch for \u201cOpenJDK\u201d and install\/reinstall Java:<\/p>\n<pre class=\"linux-code\"><code>sudo add-apt-repository ppa:no1wantdthisname\/openjdk-fontfix\r\nsudo apt-get update<\/code><\/pre>\n<p><strong>OpenJDK7<\/strong> (e.g. Ubuntu 14.04 LTS):<\/p>\n<pre class=\"linux-code\"><code>sudo apt-get install openjdk-7-jdk<\/code><\/pre>\n<p><strong>OpenJDK8<\/strong> (e.g. Ubuntu 15.04 or higher):<\/p>\n<pre class=\"linux-code\"><code>sudo apt-get install openjdk-8-jdk<\/code><\/pre>\n<p>Once installed, log out and log back in at the latest.<\/p>\n<p>The following screenshot shows the Java-IDE \u201cNetbeans\u201d after applying this how-to:<\/p>\n<p><a href=\"https:\/\/blog.hani-ibrahim.de\/wp-content\/uploads\/netbeans_ubuntu-gtk.jpg\" data-rel=\"lightbox-gallery-z6YGF0Fl\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3635\" src=\"https:\/\/blog.hani-ibrahim.de\/wp-content\/uploads\/netbeans_ubuntu-gtk-1024x625.jpg\" alt=\"netbeans_ubuntu-gtk\" width=\"474\" height=\"289\" srcset=\"https:\/\/blog.hani-ibrahim.de\/wp-content\/uploads\/netbeans_ubuntu-gtk-1024x625.jpg 1024w, https:\/\/blog.hani-ibrahim.de\/wp-content\/uploads\/netbeans_ubuntu-gtk-300x183.jpg 300w, https:\/\/blog.hani-ibrahim.de\/wp-content\/uploads\/netbeans_ubuntu-gtk.jpg 1128w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\"><\/a><\/p>\n<h3 id=\"h2\">How to revert the changes<\/h3>\n<p>To revert the changes made above use the following commands:<\/p>\n<pre class=\"linux-code\"><code>sudo apt-get --purge remove jayatana libjayatana libjayatanaag libjayatana-java libjayatanaag-java\r\n<\/code><\/pre>\n<pre class=\"linux-code\"><code>sudo apt-get purge fontconfig-infinality\r\nsudo apt-get install ppa-purge\r\nsudo ppa-purge ppa:no1wantdthisname\/ppa\r\n<\/code><\/pre>\n<pre class=\"linux-code\"><code>sudo ppa-purge ppa:no1wantdthisname\/openjdk-fontfix<\/code><\/pre>\n<p>Finally reinstall Java (OpenJDK7 <em>oder<\/em> OpenJDK8).<\/p>\n<pre class=\"linux-code\"><code>sudo apt-get remove openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless\r\nsudo apt-get install openjdk-7-jre-headless openjdk-7-jre openjdk-7-jdk<\/code><\/pre>\n<p class=\"linux-code\"><code>or<br>\n<\/code><\/p>\n<pre class=\"linux-code\"><code>sudo apt-get remove openjdk-8-jdk openjdk-8-jre openjdk-8-jre-headless\r\nsudo apt-get install openjdk-8-jre-headless openjdk-8-jre openjdk-8-jdk<\/code><\/pre>\n<p>Once finished, log out and log back.<\/p>\n<h3 id=\"h3\">Related Links<\/h3>\n<ul>\n<li><a href=\"http:\/\/www.webupd8.org\/2014\/02\/get-unity-global-menu-hud-support-for.html\" target=\"_blank\" rel=\"noopener noreferrer\">Get Unity Global Menu \/ HUD Support For Java Swing Applications With JAyatana <\/a><\/li>\n<li><a href=\"http:\/\/www.webupd8.org\/2013\/06\/better-font-rendering-in-linux-with.html\" target=\"_blank\" rel=\"noopener noreferrer\">Better Font Rendering In Linux With Infinality <\/a><\/li>\n<li><a href=\"http:\/\/www.webupd8.org\/2013\/06\/install-openjdk-patched-with-font-fixes.html\" target=\"_blank\" rel=\"noopener noreferrer\">Install OpenJDK Patched With Font Fixes<\/a><\/li>\n<\/ul>\n<p>\u00a0<\/p><\/body>","protected":false},"excerpt":{"rendered":"<div class=\"shariff shariff-align-left shariff-widget-align-left\" data-services=\"facebook\" data-url=\"https:\/\/blog.hani-ibrahim.de\/en\/ubuntus-swing-gtk-laf.html\" data-timestamp=\"1602095314\" data-backendurl=\"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/shariff\/v1\/share_counts?\"><ul class=\"shariff-buttons theme-round orientation-horizontal buttonsize-small\"><li class=\"shariff-button facebook shariff-nocustomcolor\" style=\"background-color:#4273c8;border-radius:50%\"><a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fblog.hani-ibrahim.de%2Fen%2Fubuntus-swing-gtk-laf.html\" title=\"Share on Facebook\" aria-label=\"Share on Facebook\" role=\"button\" rel=\"nofollow\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#3b5998; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 18 32\"><path fill=\"#3b5998\" d=\"M17.1 0.2v4.7h-2.8q-1.5 0-2.1 0.6t-0.5 1.9v3.4h5.2l-0.7 5.3h-4.5v13.6h-5.5v-13.6h-4.5v-5.3h4.5v-3.9q0-3.3 1.9-5.2t5-1.8q2.6 0 4.1 0.2z\"\/><\/svg><\/span><span data-service=\"facebook\" style=\"color:#3b5998\" class=\"shariff-count shariff-hidezero\"><\/span>&nbsp;<\/a><\/li><li class=\"shariff-button twitter shariff-nocustomcolor\" style=\"background-color:#595959;border-radius:50%\"><a href=\"https:\/\/twitter.com\/share?url=https%3A%2F%2Fblog.hani-ibrahim.de%2Fen%2Fubuntus-swing-gtk-laf.html&text=Java%E2%80%99s%20Swing%20GTK%20LaF%20nice%20and%20pretty%20on%20Ubuntu\" title=\"Share on X\" aria-label=\"Share on X\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#000; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\"><path fill=\"#000\" d=\"M14.258 10.152L23.176 0h-2.113l-7.747 8.813L7.133 0H0l9.352 13.328L0 23.973h2.113l8.176-9.309 6.531 9.309h7.133zm-2.895 3.293l-.949-1.328L2.875 1.56h3.246l6.086 8.523.945 1.328 7.91 11.078h-3.246zm0 0\"\/><\/svg><\/span><\/a><\/li><li class=\"shariff-button pocket shariff-nocustomcolor\" style=\"background-color:#444;border-radius:50%\"><a href=\"https:\/\/getpocket.com\/save?url=https%3A%2F%2Fblog.hani-ibrahim.de%2Fen%2Fubuntus-swing-gtk-laf.html&title=Java%E2%80%99s%20Swing%20GTK%20LaF%20nice%20and%20pretty%20on%20Ubuntu\" title=\"Save to Pocket\" aria-label=\"Save to Pocket\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#ff0000; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 27 28\"><path fill=\"#ff0000\" d=\"M24.5 2q1 0 1.7 0.7t0.7 1.7v8.1q0 2.8-1.1 5.3t-2.9 4.3-4.3 2.9-5.2 1.1q-2.7 0-5.2-1.1t-4.3-2.9-2.9-4.3-1.1-5.2v-8.1q0-1 0.7-1.7t1.7-0.7h22zM13.5 18.6q0.7 0 1.3-0.5l6.3-6.1q0.6-0.5 0.6-1.3 0-0.8-0.5-1.3t-1.3-0.5q-0.7 0-1.3 0.5l-5 4.8-5-4.8q-0.5-0.5-1.3-0.5-0.8 0-1.3 0.5t-0.5 1.3q0 0.8 0.6 1.3l6.3 6.1q0.5 0.5 1.3 0.5z\"\/><\/svg><\/span><\/a><\/li><li class=\"shariff-button rss shariff-nocustomcolor\" style=\"background-color:#ff8c00;border-radius:50%\"><a href=\"https:\/\/blog.hani-ibrahim.de\/en\/feed\/rss\" title=\"RSS feed\" aria-label=\"RSS feed\" role=\"button\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#fe9312; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#fe9312\" d=\"M4.3 23.5c-2.3 0-4.3 1.9-4.3 4.3 0 2.3 1.9 4.2 4.3 4.2 2.4 0 4.3-1.9 4.3-4.2 0-2.3-1.9-4.3-4.3-4.3zM0 10.9v6.1c4 0 7.7 1.6 10.6 4.4 2.8 2.8 4.4 6.6 4.4 10.6h6.2c0-11.7-9.5-21.1-21.1-21.1zM0 0v6.1c14.2 0 25.8 11.6 25.8 25.9h6.2c0-17.6-14.4-32-32-32z\"\/><\/svg><\/span><\/a><\/li><li class=\"shariff-button mailto shariff-nocustomcolor\" style=\"background-color:#a8a8a8;border-radius:50%\"><a href=\"mailto:?body=https%3A%2F%2Fblog.hani-ibrahim.de%2Fen%2Fubuntus-swing-gtk-laf.html&subject=Java%E2%80%99s%20Swing%20GTK%20LaF%20nice%20and%20pretty%20on%20Ubuntu\" title=\"Send by email\" aria-label=\"Send by email\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#999; color:#fff\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#999\" d=\"M32 12.7v14.2q0 1.2-0.8 2t-2 0.9h-26.3q-1.2 0-2-0.9t-0.8-2v-14.2q0.8 0.9 1.8 1.6 6.5 4.4 8.9 6.1 1 0.8 1.6 1.2t1.7 0.9 2 0.4h0.1q0.9 0 2-0.4t1.7-0.9 1.6-1.2q3-2.2 8.9-6.1 1-0.7 1.8-1.6zM32 7.4q0 1.4-0.9 2.7t-2.2 2.2q-6.7 4.7-8.4 5.8-0.2 0.1-0.7 0.5t-1 0.7-0.9 0.6-1.1 0.5-0.9 0.2h-0.1q-0.4 0-0.9-0.2t-1.1-0.5-0.9-0.6-1-0.7-0.7-0.5q-1.6-1.1-4.7-3.2t-3.6-2.6q-1.1-0.7-2.1-2t-1-2.5q0-1.4 0.7-2.3t2.1-0.9h26.3q1.2 0 2 0.8t0.9 2z\"\/><\/svg><\/span><\/a><\/li><li class=\"shariff-button whatsapp shariff-nocustomcolor\" style=\"background-color:#5cbe4a;border-radius:50%\"><a href=\"https:\/\/api.whatsapp.com\/send?text=https%3A%2F%2Fblog.hani-ibrahim.de%2Fen%2Fubuntus-swing-gtk-laf.html%20Java%E2%80%99s%20Swing%20GTK%20LaF%20nice%20and%20pretty%20on%20Ubuntu\" title=\"Share on Whatsapp\" aria-label=\"Share on Whatsapp\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\";border-radius:50%; background-color:#34af23; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#34af23\" d=\"M17.6 17.4q0.2 0 1.7 0.8t1.6 0.9q0 0.1 0 0.3 0 0.6-0.3 1.4-0.3 0.7-1.3 1.2t-1.8 0.5q-1 0-3.4-1.1-1.7-0.8-3-2.1t-2.6-3.3q-1.3-1.9-1.3-3.5v-0.1q0.1-1.6 1.3-2.8 0.4-0.4 0.9-0.4 0.1 0 0.3 0t0.3 0q0.3 0 0.5 0.1t0.3 0.5q0.1 0.4 0.6 1.6t0.4 1.3q0 0.4-0.6 1t-0.6 0.8q0 0.1 0.1 0.3 0.6 1.3 1.8 2.4 1 0.9 2.7 1.8 0.2 0.1 0.4 0.1 0.3 0 1-0.9t0.9-0.9zM14 26.9q2.3 0 4.3-0.9t3.6-2.4 2.4-3.6 0.9-4.3-0.9-4.3-2.4-3.6-3.6-2.4-4.3-0.9-4.3 0.9-3.6 2.4-2.4 3.6-0.9 4.3q0 3.6 2.1 6.6l-1.4 4.2 4.3-1.4q2.8 1.9 6.2 1.9zM14 2.2q2.7 0 5.2 1.1t4.3 2.9 2.9 4.3 1.1 5.2-1.1 5.2-2.9 4.3-4.3 2.9-5.2 1.1q-3.5 0-6.5-1.7l-7.4 2.4 2.4-7.2q-1.9-3.2-1.9-6.9 0-2.7 1.1-5.2t2.9-4.3 4.3-2.9 5.2-1.1z\"\/><\/svg><\/span><\/a><\/li><li class=\"shariff-button info shariff-nocustomcolor\" style=\"background-color:#eee;border-radius:50%\"><a href=\"http:\/\/ct.de\/-2467514\" title=\"More information\" aria-label=\"More information\" role=\"button\" rel=\"noopener \" class=\"shariff-link\" style=\";border-radius:50%; background-color:#fff; color:#fff\" target=\"_blank\"><span class=\"shariff-icon\" style=\"\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 11 32\"><path fill=\"#999\" d=\"M11.4 24v2.3q0 0.5-0.3 0.8t-0.8 0.4h-9.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h1.1v-6.8h-1.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h6.8q0.5 0 0.8 0.4t0.4 0.8v10.3h1.1q0.5 0 0.8 0.4t0.3 0.8zM9.2 3.4v3.4q0 0.5-0.4 0.8t-0.8 0.4h-4.6q-0.4 0-0.8-0.4t-0.4-0.8v-3.4q0-0.4 0.4-0.8t0.8-0.4h4.6q0.5 0 0.8 0.4t0.4 0.8z\"\/><\/svg><\/span><\/a><\/li><\/ul><\/div><p>Sorry, this entry is only available in Deutsch.<\/p>\n","protected":false},"author":2,"featured_media":3632,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[24,25,6,45,63,8],"tags":[95,134,121,135,69],"class_list":["post-3609","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-german","category-english","category-gnu-linux","category-how-tos","category-java","category-ubuntu","tag-featured","tag-gtk","tag-java","tag-laf","tag-swing"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/posts\/3609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/comments?post=3609"}],"version-history":[{"count":29,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/posts\/3609\/revisions"}],"predecessor-version":[{"id":4558,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/posts\/3609\/revisions\/4558"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/media\/3632"}],"wp:attachment":[{"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/media?parent=3609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/categories?post=3609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hani-ibrahim.de\/en\/wp-json\/wp\/v2\/tags?post=3609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}