1 /*
2 * JScroll - the scrollable desktop pane for Java.
3 * Copyright (C) 2003 Tom Tessier
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21 package org.jscroll.widgets;
22
23 import javax.swing.*;
24
25 import java.awt.*;
26
27 import java.beans.PropertyVetoException;
28
29
30 /***
31 * This class provides a custom desktop manager for
32 * {@link org.jscroll.widgets.RootDesktopPane RootDesktopPane}.
33 *
34 * @author <a href="mailto:tessier@gabinternet.com">Tom Tessier</a>
35 * @version 1.0 9-Aug-2001
36 */
37 public class JScrollDesktopManager extends DefaultDesktopManager {
38 private RootDesktopPane desktopPane;
39
40 /***
41 * creates the JScrollDesktopManager
42 *
43 * @param desktopPane a reference to RootDesktopPane
44 */
45 public JScrollDesktopManager(RootDesktopPane desktopPane) {
46 this.desktopPane = desktopPane;
47 }
48
49 /***
50 * maximizes the internal frame to the viewport bounds rather
51 * than the desktop bounds
52 *
53 * @param f the internal frame being maximized
54 */
55 public void maximizeFrame(JInternalFrame f) {
56 Rectangle p = desktopPane.getScrollPaneRectangle();
57 f.setNormalBounds(f.getBounds());
58 setBoundsForFrame(f, p.x, p.y, p.width, p.height);
59
60 try {
61 f.setSelected(true);
62 } catch (PropertyVetoException pve) {
63 System.out.println(pve.getMessage());
64 }
65
66 removeIconFor(f);
67 }
68
69 /***
70 * insures that the associated toolbar and menu buttons of
71 * the internal frame are activated as well
72 *
73 * @param f the internal frame being activated
74 */
75 public void activateFrame(JInternalFrame f) {
76 super.activateFrame(f);
77 ((JScrollInternalFrame) f).selectFrameAndAssociatedButtons();
78 }
79
80 /***
81 * closes the internal frame and removes any associated button
82 * and menu components
83 *
84 * @param f the internal frame being closed
85 */
86 public void closeFrame(JInternalFrame f) {
87 super.closeFrame(f);
88
89 // possible to retrieve the associated buttons right here via
90 // f.getAssociatedButton(), and then with a call to getParent() the item
91 // can be directly removed from its parent container, but I find the
92 // below message propogation to DesktopPane a cleaner implementation...
93 desktopPane.removeAssociatedComponents((JScrollInternalFrame) f);
94 desktopPane.resizeDesktop();
95 }
96
97 /* could override iconifyFrame here as well, but much simpler
98 to define an EmptyDesktopIconUI look and feel class in RootDesktopPane */
99 }
This page was automatically generated by Maven