001: /**
002: * L2FProd.com Common Components 7.3 License.
003: *
004: * Copyright 2005-2007 L2FProd.com
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package com.l2fprod.common.demo;
018:
019: import com.l2fprod.common.Version;
020: import com.l2fprod.common.swing.plaf.LookAndFeelAddons;
021:
022: import java.awt.BorderLayout;
023: import java.awt.Color;
024: import java.awt.Graphics2D;
025: import java.awt.RenderingHints;
026:
027: import javax.swing.BorderFactory;
028: import javax.swing.JComponent;
029: import javax.swing.JEditorPane;
030: import javax.swing.JFrame;
031: import javax.swing.JPanel;
032: import javax.swing.JTabbedPane;
033: import javax.swing.UIManager;
034:
035: /**
036: * Brings all demo together. <br>
037: *
038: */
039: public class Main extends JPanel {
040:
041: public Main() {
042: setLayout(new BorderLayout());
043:
044: JTabbedPane tabs = new JTabbedPane();
045: add("Center", tabs);
046:
047: addDemo(tabs, "JButtonBar", "ButtonBarMain");
048: addDemo(tabs, "JDirectoryChooser", "ChooseDirectory");
049: addDemo(tabs, "JFontChooser", "ChooseFont");
050: addDemo(tabs, "JOutlookBar", "OutlookBarMain");
051: addDemo(tabs, "JTaskPane", "TaskPaneMain");
052: addDemo(tabs, "PropertySheet", "PropertySheetMain");
053: addDemo(tabs, "JTipOfTheDay", "TOTDTest");
054:
055: try {
056: JEditorPane pane = new JEditorPane("text/html", "<html>") {
057: protected void paintComponent(java.awt.Graphics g) {
058: Graphics2D g2d = (Graphics2D) g;
059: g2d.setRenderingHint(
060: RenderingHints.KEY_TEXT_ANTIALIASING,
061: RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
062: super .paintComponent(g);
063: }
064: };
065: pane.setPage(Main.class.getResource("demo.html"));
066: pane.setBackground(Color.white);
067: pane.setEditable(false);
068: pane.setOpaque(true);
069: add("South", pane);
070: } catch (Exception e) {
071: }
072: }
073:
074: void addDemo(JTabbedPane tabs, String title, String demoClass) {
075: String prefix = "com.l2fprod.common.demo.";
076: LookAndFeelAddons addon = LookAndFeelAddons.getAddon();
077: try {
078: JComponent component = (JComponent) Class.forName(
079: prefix + demoClass).newInstance();
080: component.setBorder(BorderFactory.createEmptyBorder(10, 10,
081: 10, 10));
082: tabs.addTab(title, component);
083: } catch (Exception e) {
084: } finally {
085: try {
086: LookAndFeelAddons.setAddon(addon.getClass());
087: } catch (InstantiationException e1) {
088: e1.printStackTrace();
089: } catch (IllegalAccessException e1) {
090: e1.printStackTrace();
091: }
092: }
093: }
094:
095: public static void main(String[] args) throws Exception {
096: UIManager.setLookAndFeel(UIManager
097: .getSystemLookAndFeelClassName());
098:
099: JFrame frame = new JFrame("L2FProd.com Common Components "
100: + Version.getVersion() + " (build "
101: + Version.getBuildTimestamp() + ")");
102: frame.getContentPane().setLayout(new BorderLayout());
103: frame.getContentPane().add("Center", new Main());
104: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
105: frame.setSize(450, 550);
106: frame.setLocation(100, 100);
107: frame.setVisible(true);
108: }
109:
110: }
|