From fc0e8b6e20397b6ad0a868e22e1a6b9f772b75d6 Mon Sep 17 00:00:00 2001 From: Albert Cardona Date: Tue, 21 Apr 2009 15:24:24 -0400 Subject: [PATCH] Better setup of look and feel for linux. --- ini/trakem2/ControlWindow.java | 31 ++++++++++++++++++++----------- ini/trakem2/Project.java | 7 +++---- ini/trakem2/display/Display.java | 1 + 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ini/trakem2/ControlWindow.java b/ini/trakem2/ControlWindow.java index e98700a0..724271a2 100644 --- a/ini/trakem2/ControlWindow.java +++ b/ini/trakem2/ControlWindow.java @@ -77,19 +77,28 @@ public class ControlWindow { Loader.setupPreloader(this); if (IJ.isWindows() && isGUIEnabled()) StdOutWindow.start(); Display3D.init(); - /* // Nimbus looks great but it's unstable: after a while, swing components stop repainting, throwing all sort of exceptions. - if ("albert".equals(System.getProperty("user.name"))) { - try { - UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); - if (null != frame) SwingUtilities.updateComponentTreeUI(frame); - Display.updateComponentTreeUI(); - } catch (ClassNotFoundException cnfe) { - Utils.log2("Could not find Nimbus L&F"); - } catch (Exception e) { - IJError.print(e); + setLookAndFeel(); + } + } + + static public void setLookAndFeel() { + try { + if (ij.IJ.isLinux()) { + // Nimbus looks great but it's unstable: after a while, swing components stop repainting, throwing all sort of exceptions. + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + for (final Frame frame : Frame.getFrames()) { + if (frame.isEnabled()) SwingUtilities.updateComponentTreeUI(frame); } + // all done above + //if (null != frame) SwingUtilities.updateComponentTreeUI(frame); + //if (null != IJ.getInstance()) javax.swing.SwingUtilities.updateComponentTreeUI(IJ.getInstance()); + //Display.updateComponentTreeUI(); } - */ + } catch (ClassNotFoundException cnfe) { + Utils.log2("Could not find Nimbus L&F"); + } catch (Exception e) { + IJError.print(e); } } diff --git a/ini/trakem2/Project.java b/ini/trakem2/Project.java index fabe79db..8fc9c319 100644 --- a/ini/trakem2/Project.java +++ b/ini/trakem2/Project.java @@ -65,19 +65,18 @@ import javax.swing.UIManager; /** The top-level class in control. */ public class Project extends DBObject { - /* static { try { //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (IJ.isLinux()) { - //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); - if ("albert".equals(System.getProperty("user.name"))) UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + if (null != IJ.getInstance()) javax.swing.SwingUtilities.updateComponentTreeUI(IJ.getInstance()); + //if ("albert".equals(System.getProperty("user.name"))) UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } } catch (Exception e) { Utils.log("Failed to set System Look and Feel"); } } - */ /* // using virtual frame buffer instead, since the trees are needed public static final boolean headless = isHeadless(); diff --git a/ini/trakem2/display/Display.java b/ini/trakem2/display/Display.java index e6b253b6..6ea647f5 100644 --- a/ini/trakem2/display/Display.java +++ b/ini/trakem2/display/Display.java @@ -793,6 +793,7 @@ public final class Display extends DBObject implements ActionListener, ImageList public void run() { tabs.setMinimumSize(new Dimension(0, 100)); Display.scrollbar_width = Display.this.scroll_patches.getVerticalScrollBar().getPreferredSize().width; // using scroll_patches since it's the one selected by default and thus visible and painted + ControlWindow.setLookAndFeel(); } }); } -- 2.11.4.GIT