JTattoo and NetBeans Platform

A first attempt at JTattoo usage in a NetBeans Platform application.

To achieve the above, create a new module that wraps JTattoo, and in a different module set a dependency on the JTattoo module and then include the following:

@OnStart
public class Startable implements Runnable {
    @Override
    public void run() {
        try {
            UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Startable.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

Any NetBeans Platform developers using JTattoo out there, would be great to hear your opinions on it, and any tips and tricks.

Comments:

An utility enum class I use to get access to JTattoo capabilities.

import com.jtattoo.plaf.AbstractTheme;
import com.jtattoo.plaf.acryl.AcrylLookAndFeel;
import com.jtattoo.plaf.aero.AeroLookAndFeel;
import com.jtattoo.plaf.aluminium.AluminiumLookAndFeel;
import com.jtattoo.plaf.bernstein.BernsteinLookAndFeel;
import com.jtattoo.plaf.fast.FastLookAndFeel;
import com.jtattoo.plaf.graphite.GraphiteLookAndFeel;
import com.jtattoo.plaf.hifi.HiFiLookAndFeel;
import com.jtattoo.plaf.luna.LunaLookAndFeel;
import com.jtattoo.plaf.mcwin.McWinLookAndFeel;
import com.jtattoo.plaf.mint.MintLookAndFeel;
import com.jtattoo.plaf.noire.NoireLookAndFeel;
import com.jtattoo.plaf.smart.SmartLookAndFeel;
import com.jtattoo.plaf.texture.TextureLookAndFeel;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;

/**
<p/>
@author Administrator
*/
public enum JTattooSkins {

/**
<p/>
*/
Fast {
private final FastLookAndFeel fast = new FastLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = FastLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
FastLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = FastLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
FastLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return FastLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.fast.FastLookAndFeel";
}

@Override
public String getName() {
return fast.getName();
}

@Override
public String getID() {
return fast.getID();
}

@Override
public String getDescription() {
return fast.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return FastLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Smart {
private final SmartLookAndFeel smart = new SmartLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = SmartLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
SmartLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = SmartLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
SmartLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return SmartLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.smart.SmartLookAndFeel";
}

@Override
public String getName() {
return smart.getName();
}

@Override
public String getID() {
return smart.getID();
}

@Override
public String getDescription() {
return smart.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return SmartLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Acryl {
private final AcrylLookAndFeel acryl = new AcrylLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = AcrylLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
AcrylLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = AcrylLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
AcrylLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return AcrylLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.acryl.AcrylLookAndFeel";
}

@Override
public String getName() {
return acryl.getName();
}

@Override
public String getID() {
return acryl.getID();
}

@Override
public String getDescription() {
return acryl.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return AcrylLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Aero {
private final AeroLookAndFeel aero = new AeroLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = AeroLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
AeroLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = AeroLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
AeroLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return AeroLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.aero.AeroLookAndFeel";
}

@Override
public String getName() {
return aero.getName();
}

@Override
public String getID() {
return aero.getID();
}

@Override
public String getDescription() {
return aero.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return AeroLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Bernstein {
private final BernsteinLookAndFeel bernstein = new BernsteinLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = BernsteinLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
BernsteinLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = BernsteinLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
BernsteinLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return BernsteinLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.bernstein.BernsteinLookAndFeel";
}

@Override
public String getName() {
return bernstein.getName();
}

@Override
public String getID() {
return bernstein.getID();
}

@Override
public String getDescription() {
return bernstein.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return BernsteinLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Aluminium {
private final AluminiumLookAndFeel aluminium = new AluminiumLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = AluminiumLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
AluminiumLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = AluminiumLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
AluminiumLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return AluminiumLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel";
}

@Override
public String getName() {
return aluminium.getName();
}

@Override
public String getID() {
return aluminium.getID();
}

@Override
public String getDescription() {
return aluminium.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return AluminiumLookAndFeel.getThemes();
}
},
/**
<p/>
*/
McWin {
private final McWinLookAndFeel macWin = new McWinLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = McWinLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
McWinLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = McWinLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
McWinLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return McWinLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.mcwin.McWinLookAndFeel";
}

@Override
public String getName() {
return macWin.getName();
}

@Override
public String getID() {
return macWin.getID();
}

@Override
public String getDescription() {
return macWin.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return McWinLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Mint {
private final MintLookAndFeel mint = new MintLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = MintLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
MintLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = MintLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
MintLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return MintLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.mint.MintLookAndFeel";
}

@Override
public String getName() {
return mint.getName();
}

@Override
public String getID() {
return mint.getID();
}

@Override
public String getDescription() {
return mint.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return MintLookAndFeel.getThemes();
}
},
/**
<p/>
*/
HiFi {
private final HiFiLookAndFeel hifi = new HiFiLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = HiFiLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
HiFiLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = HiFiLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
HiFiLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return HiFiLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.hifi.HiFiLookAndFeel";
}

@Override
public String getName() {
return hifi.getName();
}

@Override
public String getID() {
return hifi.getID();
}

@Override
public String getDescription() {
return hifi.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return HiFiLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Noire {
private final NoireLookAndFeel noire = new NoireLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = NoireLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
NoireLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = NoireLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
NoireLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return NoireLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.noire.NoireLookAndFeel";
}

@Override
public String getName() {
return noire.getName();
}

@Override
public String getID() {
return noire.getID();
}

@Override
public String getDescription() {
return noire.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return NoireLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Luna {
private final LunaLookAndFeel luna = new LunaLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = LunaLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
LunaLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = LunaLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
LunaLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return LunaLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.luna.LunaLookAndFeel";
}

@Override
public String getName() {
return luna.getName();
}

@Override
public String getID() {
return luna.getID();
}

@Override
public String getDescription() {
return luna.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return LunaLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Graphite {
private final GraphiteLookAndFeel graphite = new GraphiteLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = GraphiteLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
GraphiteLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = GraphiteLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
GraphiteLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return GraphiteLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.graphite.GraphiteLookAndFeel";
}

@Override
public String getName() {
return graphite.getName();
}

@Override
public String getID() {
return graphite.getID();
}

@Override
public String getDescription() {
return graphite.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return GraphiteLookAndFeel.getThemes();
}
},
/**
<p/>
*/
Texture {
private final TextureLookAndFeel texture = new TextureLookAndFeel();

@Override
public void setTattooTheme(String theme, String logo) {
final Properties props = TextureLookAndFeel.getThemeProperties(theme);
props.setProperty("logoString", logo);
TextureLookAndFeel.setTheme(props);
}

@Override
public void setTattooTheme(AbstractTheme theme, String logo) {
final Properties props = TextureLookAndFeel.getThemeProperties(theme.getName());
props.setProperty("logoString", logo);
TextureLookAndFeel.setTheme(props);
}

@Override
public AbstractTheme getTattooTheme() {
return TextureLookAndFeel.getTheme();
}

@Override
public String getTattooClassName() {
return "com.jtattoo.plaf.texture.TextureLookAndFeel";
}

@Override
public String getName() {
return texture.getName();
}

@Override
public String getID() {
return texture.getID();
}

@Override
public String getDescription() {
return texture.getDescription();
}

@SuppressWarnings(value = "unchecked")
@Override
public List<String> getTattooThemes() {
return TextureLookAndFeel.getThemes();
}
};
private static final HashMap<String, JTattooSkins> namesLookup;

static {
namesLookup = new HashMap<>(2 * JTattooSkins.values().length);
for (final Iterator<JTattooSkins> it = EnumSet.allOf(JTattooSkins.class).iterator(); it.hasNext();) {
final JTattooSkins skin = it.next();
namesLookup.put(skin.getName(), skin);
}
}

/**
<p/>
@return
*/
public abstract String getTattooClassName();

/**
<p/>
@return
*/
public abstract String getName();

/**
<p/>
@return
*/
public abstract String getID();

/**
<p/>
@return
*/
public abstract String getDescription();

/**
<p/>
@return
*/
public abstract List<String> getTattooThemes();

/**
<p/>
@return
*/
public abstract AbstractTheme getTattooTheme();

/**
<p/>
@param theme
@param logo
*/
public abstract void setTattooTheme(String theme, String logo);

/**
<p/>
@param theme
@param logo
*/
public abstract void setTattooTheme(AbstractTheme theme, String logo);

/**
<p/>
@param laFname
<
p/>
<p/>
@return
*/
public static String getClassName(final String laFname) {
return namesLookup.get(laFname).getTattooClassName();
}

/**
<p/>
@param laFname
<
p/>
<p/>
@return
*/
public static List<String> getThemes(final String laFname) {
return namesLookup.get(laFname).getTattooThemes();
}

/**
<p/>
@param laFname
@param theme
@param logo
*/
public static void setTheme(final String laFname, final String theme, final String logo) {
namesLookup.get(laFname).setTattooTheme(theme, logo);
}

/**
<p/>
@param laFname
@param theme
@param logo
*/
public static void setTheme(final String laFname, final AbstractTheme theme, final String logo) {
namesLookup.get(laFname).setTattooTheme(theme, logo);
}

/**
<p/>
@param laFname
<
p/>
<p/>
@return
*/
public static AbstractTheme getTheme(final String laFname) {
return namesLookup.get(laFname).getTattooTheme();
}

/**
<p/>
@return
*/
public static Set<String> getNames() {
return Collections.unmodifiableSet(namesLookup.keySet());
}

/**
<p/>
@param name
<p/>
@return
*/
public static boolean isJTattoo(final String name) {
return namesLookup.keySet().contains(name);
}

}

Posted by guest on January 20, 2014 at 01:41 AM PST #

Thank you! Very useful.

Posted by Geertjan on January 20, 2014 at 11:07 AM PST #

I have a test .:)

and I found there would be a bug.

when using the theme of com.jtattoo.plaf.texture.TextureLookAndFeel

it makes NetBeans can't moveable.

Which My Environment is NB 8.0 beta under ubuntu 13.10. and openjdk 1.7

Posted by fortruth on January 21, 2014 at 07:49 PM PST #

I have just run JTattoo demo test on top of JavaSE 1.8 and found no issues for Texture L&F themes.

Posted by Carlos Hoces on January 22, 2014 at 01:17 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today