Skip to content
Browse files

fix for proper L&F selection under non-GNOME Linux + maximized state …

…under Linux fix
  • Loading branch information...
1 parent dd1115d commit 9b240d271ef78e09403b1dea184f355cc4f473fa @jacek99 committed Dec 9, 2011
View
8 ...builder-swing-samples/src/main/java/org/javabuilders/swing/samples/SwingSamplesFrame.java
@@ -29,12 +29,8 @@
//common init, used by unit tests as well
public static void init() {
try {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
- } catch (Exception ex) {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- }
+
+ SwingJavaBuilder.initSystemLookAndFeel();
//register global resource bundle
SwingGlazedListsConfig.init();
View
27 ...swing-parent/javabuilder-swing/src/main/java/org/javabuilders/swing/SwingJavaBuilder.java
@@ -5,8 +5,14 @@
import java.util.ResourceBundle;
+import javax.swing.UIManager;
+
import org.javabuilders.BuildResult;
import org.javabuilders.Builder;
+import org.javabuilders.util.BuilderUtils;
+import org.javabuilders.util.BuilderUtils.OperatingSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Swing Builder
@@ -16,6 +22,7 @@
public class SwingJavaBuilder {
private static SwingJavaBuilderConfig config = new SwingJavaBuilderConfig();
+ private static final Logger LOG = LoggerFactory.getLogger(SwingJavaBuilder.class);
public final static String VGAP = "vgap";
public final static String HGAP = "hgap";
@@ -103,5 +110,25 @@ public static BuildResult build(Object caller, String yaml, ResourceBundle...bun
return Builder.buildFromString(getConfig(),caller, yaml, bundles);
}
+ /**
+ * Workaround for buggy Sun logic where under certain Linux desktops the GTK+ look is not activated
+ */
+ public static void initSystemLookAndFeel() {
+ try {
+ String lf = UIManager.getSystemLookAndFeelClassName();
+ if (BuilderUtils.getOS() == OperatingSystem.LinuxUnix) {
+ //always use GTK+ theme, even under XFCE in Linux
+ lf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
+ }
+ UIManager.setLookAndFeel(lf);
+ } catch (Exception ex) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+ LOG.error("Unable to set proper L&F",e);
+ }
+ }
+ }
+
}
View
2 ...wing/src/main/java/org/javabuilders/swing/handler/property/FrameExtendedStateHandler.java
@@ -92,7 +92,7 @@ public void handle(BuilderConfig config, BuildProcess result, Node node,
switch (state) {
case Frame.MAXIMIZED_BOTH:
- frame.setSize(screenRect.width, screenRect.width);
+ frame.setSize(screenRect.width, screenRect.height);
break;
case Frame.MAXIMIZED_HORIZ:
frame.pack();

0 comments on commit 9b240d2

Please sign in to comment.
Something went wrong with that request. Please try again.