1 package rero.gui.mdi; 2 3 import javax.swing.*; 4 import javax.swing.event.*; 5 6 import java.awt.*; 7 import java.awt.event.*; 8 9 import java.util.*; 10 11 import rero.gui.windows.*; 12 13 public class ClientInternalWindow extends JInternalFrame implements ClientWindow, InternalFrameListener 14 { 15 protected LinkedList clisteners = new LinkedList(); 16 protected ClientWindowEvent cevent; 17 protected boolean isOpen = false; 18 19 public ClientInternalWindow() 20 { 21 super("", true, true, true, true); 22 23 cevent = new ClientWindowEvent(this); 24 addInternalFrameListener(this); 25 } 26 27 public boolean isOpen() 28 { 29 return isOpen; 30 } 31 32 public void setIcon(ImageIcon i) 33 { 34 setFrameIcon(i); 35 } 36 37 public void addWindowListener(ClientWindowListener l) 38 { 39 clisteners.add(l); 40 } 41 42 public void internalFrameActivated(InternalFrameEvent e) 43 { 44 Iterator i = clisteners.listIterator(); 45 while (i.hasNext()) 46 { 47 ClientWindowListener temp = (ClientWindowListener)i.next(); 48 temp.onActive(cevent); 49 } 50 } 51 52 public void internalFrameDeactivated(InternalFrameEvent e) 53 { 54 Iterator i = clisteners.listIterator(); 55 while (i.hasNext()) 56 { 57 ClientWindowListener temp = (ClientWindowListener)i.next(); 58 temp.onInactive(cevent); 59 } 60 } 61 62 public void internalFrameClosed(InternalFrameEvent e) 63 { 64 Iterator i = clisteners.listIterator(); 65 while (i.hasNext()) 66 { 67 ClientWindowListener temp = (ClientWindowListener)i.next(); 68 temp.onClose(cevent); 69 } 70 } 71 72 public void internalFrameClosing(InternalFrameEvent e) { } 73 74 public void internalFrameDeiconified(InternalFrameEvent e) { } 75 76 public void internalFrameIconified(InternalFrameEvent e) 77 { 78 Iterator i = clisteners.listIterator(); 79 while (i.hasNext()) 80 { 81 ClientWindowListener temp = (ClientWindowListener)i.next(); 82 temp.onMinimize(cevent); 83 } 84 } 85 86 public void internalFrameOpened(InternalFrameEvent e) 87 { 88 Iterator i = clisteners.listIterator(); 89 while (i.hasNext()) 90 { 91 ClientWindowListener temp = (ClientWindowListener)i.next(); 92 temp.onOpen(cevent); 93 } 94 } 95 96 public void closeWindow() 97 { 98 SwingUtilities.invokeLater(new Runnable () 99 { 100 public void run() 101 { 102 try { setClosed(true); } catch (Exception ex) { } 103 } 104 }); 105 } 106 107 public void setMaximum(boolean b) 108 { 109 try { super.setMaximum(b); } catch (Exception ex) { } 110 } 111 112 public void setIcon(boolean b) 113 { 114 try { super.setIcon(b); } catch (Exception ex) { } 115 } 116 117 public void setTitle(String aTitle) 118 { 119 title = aTitle; 120 revalidate(); 121 repaint(); 122 } 123 124 public void show() 125 { 126 isOpen = true; 127 super.show(); 128 } 129 130 131 public void activate() 132 { 133 SwingUtilities.invokeLater(new Runnable () 134 { 135 public void run() 136 { 137 try { 138 if (!isOpen) 139 show(); 140 141 setSelected(true); 142 } catch (Exception ex) { } 143 } 144 }); 145 } 146 } 147 | Popular Tags |