|
|
|
|
@ -5,12 +5,18 @@
|
|
|
|
|
*/
|
|
|
|
|
package org.idp.laf;
|
|
|
|
|
|
|
|
|
|
import java.util.prefs.Preferences;
|
|
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
|
import javax.swing.UIDefaults;
|
|
|
|
|
import javax.swing.UIManager;
|
|
|
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
|
|
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
|
|
|
|
import static javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme;
|
|
|
|
|
import static javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme;
|
|
|
|
|
import org.openide.util.Exceptions;
|
|
|
|
|
import org.openide.util.NbBundle;
|
|
|
|
|
import org.openide.util.NbPreferences;
|
|
|
|
|
import org.openide.windows.WindowManager;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Edward M. Kagan <pagan@idp-crew.com>
|
|
|
|
|
@ -19,7 +25,61 @@ public class TitanLookAndFeel extends MetalLookAndFeel {
|
|
|
|
|
|
|
|
|
|
public static void self_install ()
|
|
|
|
|
{
|
|
|
|
|
UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
|
|
|
|
|
for (UIManager.LookAndFeelInfo lafi : installedLookAndFeels)
|
|
|
|
|
{
|
|
|
|
|
String laf_name = NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN");
|
|
|
|
|
if (lafi.getName().equals(laf_name))
|
|
|
|
|
{
|
|
|
|
|
System.out.println("LAF Persist - no install.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.print("NO LAF - installing... ");
|
|
|
|
|
UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo( NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN"), TitanLookAndFeel.class.getName()) );
|
|
|
|
|
System.out.println("OK");
|
|
|
|
|
|
|
|
|
|
System.out.print("Applying LAf... ");
|
|
|
|
|
Preferences prefs = NbPreferences.root().node( "laf" ); //NOI18N
|
|
|
|
|
prefs.put( "laf", TitanLookAndFeel.class.getName() ); //NOI18N
|
|
|
|
|
System.out.println("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void self_remove ()
|
|
|
|
|
{
|
|
|
|
|
UIManager.LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
|
|
|
|
|
|
|
|
|
|
for (UIManager.LookAndFeelInfo lafi : installedLookAndFeels)
|
|
|
|
|
{
|
|
|
|
|
String laf_name = NbBundle.getMessage(TitanLookAndFeel.class, "LBL_TITAN");
|
|
|
|
|
if (lafi.getName().equals(laf_name))
|
|
|
|
|
{
|
|
|
|
|
System.out.print("LAF Persist - removing...");
|
|
|
|
|
int i = 0;
|
|
|
|
|
UIManager.LookAndFeelInfo[] toSet = new UIManager.LookAndFeelInfo[installedLookAndFeels.length - 1];
|
|
|
|
|
for (UIManager.LookAndFeelInfo copy : installedLookAndFeels)
|
|
|
|
|
{
|
|
|
|
|
if (!copy.getName().equals(laf_name))
|
|
|
|
|
{
|
|
|
|
|
toSet[i] = copy;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UIManager.setInstalledLookAndFeels(toSet);
|
|
|
|
|
System.out.println("OK");
|
|
|
|
|
System.out.print("Setting Metal theme by default...");
|
|
|
|
|
try {
|
|
|
|
|
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
|
|
|
|
|
System.out.print("OK");
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
|
|
System.out.print("FAIL");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("NO LAF - nothing to remove.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|