There are only two steps to select a predefined theme and set the look and feel you want:
com.jtattoo.plaf.acryl.AcrylLookAndFeel.setTheme("Green", "INSERT YOUR LICENSE KEY HERE", "my company");
UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
All look and feel's within the JTattoo package do have a static method named setTheme. The
first parameter is the name of the theme you want to select. The second parameter is the license
key (you will get one if you purchase a license) and the last parameter is the string you want
to show in the lower left corner of popup-menus. If you don't have a license key, this
will work as well, with the restriction that you can't set the string in popup-menus.
For a complete list of the predefined themes see : Predefined themes
Here's a simple demo application to illustrate the setTheme method:
package com.jtattoo.demo.app;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SimpleThemesDemo extends JFrame {
public SimpleThemesDemo() {
super("SimpleThemesDemo-Application");
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menu.setMnemonic('F');
JMenuItem menuItem = new JMenuItem("New");
menu.add(menuItem);
menuItem = new JMenuItem("Open");
menu.add(menuItem);
menuItem = new JMenuItem("Save");
menu.add(menuItem);
menuItem = new JMenuItem("Save as");
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("Exit");
menuItem.setMnemonic('x');
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_MASK));
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.exit(0);
}
});
menu.add(menuItem);
menuBar.add(menu);
setJMenuBar(menuBar);
JPanel contentPanel = new JPanel(new BorderLayout());
contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
JTree tree = new JTree();
tree.expandRow(3);
tree.expandRow(2);
tree.expandRow(1);
JScrollPane westPanel = new JScrollPane(tree);
JEditorPane editor = new JEditorPane("text/plain", "Hello World");
JScrollPane eastPanel = new JScrollPane(editor);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, westPanel,eastPanel);
splitPane.setDividerLocation(148);
contentPanel.add(splitPane, BorderLayout.CENTER);
setContentPane(contentPanel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setLocation(32, 32);
setSize(400, 300);
setVisible(true);
}
public static void main(String[] args) {
try {
com.jtattoo.plaf.acryl.AcrylLookAndFeel.setTheme("Green", "INSERT YOUR LICENSE KEY HERE", "my company");
UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
new SimpleThemesDemo();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
|