001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: PaneHandler.java,v 1.7 2005/12/04 13:46:05 jesper Exp $
023: package net.infonode.tabbedpanel.theme.internal.laftheme;
024:
025: import net.infonode.gui.DynamicUIManager;
026: import net.infonode.gui.DynamicUIManagerListener;
027: import net.infonode.util.Direction;
028:
029: import javax.swing.*;
030: import java.awt.*;
031:
032: public class PaneHandler {
033: private JFrame frame;
034:
035: private PanePainter[] panePainters;
036:
037: private PaneHandlerListener listener;
038:
039: private DynamicUIManagerListener uiListener = new DynamicUIManagerListener() {
040:
041: public void lookAndFeelChanged() {
042: doUpdate();
043: }
044:
045: public void propertiesChanging() {
046: listener.updating();
047: }
048:
049: public void propertiesChanged() {
050: doUpdate();
051: }
052:
053: public void lookAndFeelChanging() {
054: listener.updating();
055: }
056:
057: };
058:
059: PaneHandler(PaneHandlerListener listener) {
060: this .listener = listener;
061:
062: DynamicUIManager.getInstance().addPrioritizedListener(
063: uiListener);
064:
065: Direction[] directions = Direction.getDirections();
066: panePainters = new PanePainter[directions.length];
067:
068: JPanel panel = new JPanel(null);
069: for (int i = 0; i < directions.length; i++) {
070: panePainters[i] = new PanePainter(directions[i]);
071: panel.add(panePainters[i]);
072: panePainters[i].setBounds(0, 0, 600, 600);
073: }
074:
075: frame = new JFrame();
076: frame.getContentPane().add(panel, BorderLayout.CENTER);
077: frame.pack();
078: }
079:
080: void dispose() {
081: if (frame != null) {
082: DynamicUIManager.getInstance().removePrioritizedListener(
083: uiListener);
084: frame.removeAll();
085: frame.dispose();
086: frame = null;
087: }
088: }
089:
090: PanePainter getPainter(Direction d) {
091: for (int i = 0; i < panePainters.length; i++)
092: if (panePainters[i].getDirection() == d)
093: return panePainters[i];
094:
095: return null;
096: }
097:
098: JFrame getFrame() {
099: return frame;
100: }
101:
102: void update() {
103: listener.updating();
104:
105: doUpdate();
106: }
107:
108: private void doUpdate() {
109: SwingUtilities.updateComponentTreeUI(frame);
110:
111: // SwingUtilities.invokeLater(new Runnable() {
112: // public void run() {
113: listener.updated();
114: // }
115: // });
116: }
117: }
|