The following short code fragment shows you the way how to switch the Look and
Feel in your application. Be sure that the JTattooDemo.jar is in the java classpath
if you want to run this demo. The easiest way is to copy the JTattooDemo.jar into
the (java_home)/jre/lib/ext folder.
1
2
3
4
5
6 package com.jtattoo.demo.app;
7
8 import java.awt.*;
9 import java.awt.event.*;
10 import javax.swing.*;
11
12 public class MinFrame extends JFrame {
13
14 public MinFrame() {
15 super("Minimal-Frame-Application");
16
17
18 JMenuBar menuBar = new JMenuBar();
19 JMenu menu = new JMenu("File");
20 menu.setMnemonic('F');
21 JMenuItem menuItem = new JMenuItem("Exit");
22 menuItem.setMnemonic('x');
23 menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_MASK));
24 menuItem.addActionListener(new ActionListener() {
25 public void actionPerformed(ActionEvent event) {
26 System.exit(0);
27 }
28 });
29 menu.add(menuItem);
30
31 menu.add(menuItem);
32 menuBar.add(menu);
33 setJMenuBar(menuBar);
34
35
36 JPanel contentPanel = new JPanel(new BorderLayout());
37 contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
38 JScrollPane westPanel = new JScrollPane(new JTree());
39 JEditorPane editor = new JEditorPane("text/plain", "Hello World");
40 JScrollPane eastPanel = new JScrollPane(editor);
41 JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, westPanel,eastPanel);
42 splitPane.setDividerLocation(148);
43 contentPanel.add(splitPane, BorderLayout.CENTER);
44 setContentPane(contentPanel);
45
46
47 addWindowListener(new WindowAdapter() {
48 public void windowClosing(WindowEvent e) {
49 System.exit(0);
50 }
51 });
52
53
54 setLocation(32, 32);
55 setSize(400, 300);
56 setVisible(true);
57
58 }
59
60 public static void main(String[] args) {
61 try {
62
63 UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
64
65 new MinFrame();
66 }
67 catch (Exception ex) {
68 ex.printStackTrace();
69 }
70 }
71
72 }
73
74