View Javadoc
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 java.awt.event.*; 24 25 26 /*** 27 * This class provides common Component and Action Listeners for 28 * other objects in the system. 29 * 30 * @author <a href="mailto:tessier@gabinternet.com">Tom Tessier</a> 31 * @version 1.0 11-Aug-2001 32 */ 33 public class DesktopListener implements ComponentListener, ActionListener { 34 private DesktopMediator desktopMediator; 35 36 /*** 37 * creates the DesktopListener object. 38 * 39 * @param desktopMediator a reference to the DesktopMediator object 40 */ 41 public DesktopListener(DesktopMediator desktopMediator) { 42 this.desktopMediator = desktopMediator; 43 } 44 45 /// 46 // respond to component events... 47 /// 48 49 /*** 50 * updates the preferred size of the desktop when either an internal frame 51 * or the scrollable desktop pane itself is resized 52 * 53 * @param e the ComponentEvent 54 */ 55 public void componentResized(ComponentEvent e) { 56 desktopMediator.resizeDesktop(); 57 } 58 59 /*** 60 * revalidates the desktop to ensure the viewport has the proper 61 * height/width settings when a new component is shown upon the desktop 62 * 63 * @param e the ComponentEvent 64 */ 65 public void componentShown(ComponentEvent e) { 66 desktopMediator.revalidateViewport(); 67 } 68 69 /*** 70 * updates the preferred size of the desktop when a component is moved 71 * 72 * @param e the ComponentEvent 73 */ 74 public void componentMoved(ComponentEvent e) { 75 desktopMediator.resizeDesktop(); 76 } 77 78 /*** 79 * interface placeholder 80 * 81 * @param e the ComponentEvent 82 */ 83 public void componentHidden(ComponentEvent e) { 84 } 85 86 /// 87 // respond to action events... 88 /// 89 90 /*** 91 * common actionPerformed method that responds to both button 92 * and menu events. 93 * If no action command provided in the ActionEvent, selects 94 * the frame associated with the current button / menu item (if any). 95 * 96 * @param e the ActionEvent 97 */ 98 public void actionPerformed(ActionEvent e) { 99 String actionCmd = e.getActionCommand(); 100 101 if (actionCmd.equals("Tile")) { 102 desktopMediator.tileInternalFrames(); 103 } else if (actionCmd.equals("Cascade")) { 104 desktopMediator.cascadeInternalFrames(); 105 } else if (actionCmd.equals("Close")) { 106 desktopMediator.closeSelectedFrame(); 107 } 108 else if (actionCmd.equals("TileRadio")) { 109 desktopMediator.setAutoTile(true); 110 } else if (actionCmd.equals("CascadeRadio")) { 111 desktopMediator.setAutoTile(false); 112 } 113 else { // no action command? 114 // then select the associated frame (if any) 115 116 JScrollInternalFrame associatedFrame = ((FrameAccessorInterface) e.getSource()).getAssociatedFrame(); 117 118 if (associatedFrame != null) { 119 associatedFrame.selectFrameAndAssociatedButtons(); 120 desktopMediator.centerView(associatedFrame); 121 } 122 } 123 } 124 }

This page was automatically generated by Maven