1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58:
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73: import ;
74: import ;
75: import ;
76: import ;
77:
78:
81: public class BasicInternalFrameUI extends InternalFrameUI
82: {
83:
87: protected class BasicInternalFrameListener implements InternalFrameListener
88: {
89:
94: public void internalFrameActivated(InternalFrameEvent e)
95: {
96:
97: }
98:
99:
104: public void internalFrameClosed(InternalFrameEvent e)
105: {
106:
107: }
108:
109:
114: public void internalFrameClosing(InternalFrameEvent e)
115: {
116:
117: }
118:
119:
124: public void internalFrameDeactivated(InternalFrameEvent e)
125: {
126:
127: }
128:
129:
134: public void internalFrameDeiconified(InternalFrameEvent e)
135: {
136:
137: }
138:
139:
144: public void internalFrameIconified(InternalFrameEvent e)
145: {
146:
147: }
148:
149:
154: public void internalFrameOpened(InternalFrameEvent e)
155: {
156:
157: }
158: }
159:
160:
165: protected class BorderListener extends MouseInputAdapter
166: implements SwingConstants
167: {
168:
169: protected final int RESIZE_NONE = 0;
170:
171:
172: private transient int xOffset = 0;
173:
174:
175: private transient int yOffset = 0;
176:
177:
178: private transient int direction = -1;
179:
180:
181: private transient Rectangle cacheRect = new Rectangle();
182:
183:
188: public void mouseClicked(MouseEvent e)
189: {
190:
191:
192: }
193:
194:
200: public void mouseDragged(MouseEvent e)
201: {
202:
203:
204: if (frame.isMaximum())
205: return;
206: DesktopManager dm = getDesktopManager();
207: Rectangle b = frame.getBounds();
208: Dimension min = frame.getMinimumSize();
209: if (min == null)
210: min = new Dimension(0, 0);
211: Insets insets = frame.getInsets();
212: int x = e.getX();
213: int y = e.getY();
214: if (e.getSource() == frame && frame.isResizable())
215: {
216: switch (direction)
217: {
218: case NORTH:
219: cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
220: - min.height),
221: b.width, b.height - y);
222: break;
223: case NORTH_EAST:
224: cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
225: - min.height), x,
226: b.height - y);
227: break;
228: case EAST:
229: cacheRect.setBounds(b.x, b.y, x, b.height);
230: break;
231: case SOUTH_EAST:
232: cacheRect.setBounds(b.x, b.y, x, y);
233: break;
234: case SOUTH:
235: cacheRect.setBounds(b.x, b.y, b.width, y);
236: break;
237: case SOUTH_WEST:
238: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
239: b.y, b.width - x, y);
240: break;
241: case WEST:
242: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
243: b.y, b.width - x, b.height);
244: break;
245: case NORTH_WEST:
246: cacheRect.setBounds(
247: Math.min(b.x + x, b.x + b.width - min.width),
248: Math.min(b.y + y, b.y + b.height - min.height),
249: b.width - x, b.height - y);
250: break;
251: }
252: dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
253: Math.max(min.width, cacheRect.width),
254: Math.max(min.height, cacheRect.height));
255: }
256: else if (e.getSource() == titlePane)
257: {
258: Rectangle fBounds = frame.getBounds();
259:
260: dm.dragFrame(frame, e.getX() - xOffset + b.x, e.getY() - yOffset
261: + b.y);
262: }
263: }
264:
265:
270: public void mouseExited(MouseEvent e)
271: {
272:
273:
274: }
275:
276:
282: public void mouseMoved(MouseEvent e)
283: {
284:
285:
286: }
287:
288:
293: public void mousePressed(MouseEvent e)
294: {
295: activateFrame(frame);
296: DesktopManager dm = getDesktopManager();
297: int x = e.getX();
298: int y = e.getY();
299: Insets insets = frame.getInsets();
300:
301: if (e.getSource() == frame && frame.isResizable())
302: {
303: direction = sectionOfClick(x, y);
304: dm.beginResizingFrame(frame, direction);
305: }
306: else if (e.getSource() == titlePane)
307: {
308: Rectangle tBounds = titlePane.getBounds();
309:
310: xOffset = e.getX() - tBounds.x + insets.left;
311: yOffset = e.getY() - tBounds.y + insets.top;
312:
313: dm.beginDraggingFrame(frame);
314: }
315: }
316:
317:
322: public void mouseReleased(MouseEvent e)
323: {
324: DesktopManager dm = getDesktopManager();
325: xOffset = 0;
326: yOffset = 0;
327: if (e.getSource() == frame && frame.isResizable())
328: dm.endResizingFrame(frame);
329: else if (e.getSource() == titlePane)
330: dm.endDraggingFrame(frame);
331: }
332:
333:
342: private int sectionOfClick(int x, int y)
343: {
344: Insets insets = frame.getInsets();
345: Rectangle b = frame.getBounds();
346: if (x < insets.left && y < insets.top)
347: return NORTH_WEST;
348: else if (x > b.width - insets.right && y < insets.top)
349: return NORTH_EAST;
350: else if (x > b.width - insets.right && y > b.height - insets.bottom)
351: return SOUTH_EAST;
352: else if (x < insets.left && y > b.height - insets.bottom)
353: return SOUTH_WEST;
354: else if (y < insets.top)
355: return NORTH;
356: else if (x < insets.left)
357: return WEST;
358: else if (y > b.height - insets.bottom)
359: return SOUTH;
360: else if (x > b.width - insets.right)
361: return EAST;
362:
363: return -1;
364: }
365: }
366:
367:
372: protected class ComponentHandler implements ComponentListener
373: {
374:
380: public void componentHidden(ComponentEvent e)
381: {
382:
383: }
384:
385:
391: public void componentMoved(ComponentEvent e)
392: {
393:
394: }
395:
396:
402: public void componentResized(ComponentEvent e)
403: {
404: if (frame.isMaximum())
405: {
406: JDesktopPane pane = (JDesktopPane) e.getSource();
407: Insets insets = pane.getInsets();
408: Rectangle bounds = pane.getBounds();
409:
410: frame.setBounds(bounds.x + insets.left, bounds.y + insets.top,
411: bounds.width - insets.left - insets.right,
412: bounds.height - insets.top - insets.bottom);
413: frame.revalidate();
414: frame.repaint();
415: }
416:
417:
418: }
419:
420:
426: public void componentShown(ComponentEvent e)
427: {
428:
429: }
430: }
431:
432:
435: public class InternalFrameLayout implements LayoutManager
436: {
437:
446: public void addLayoutComponent(String name, Component c)
447: {
448:
449: }
450:
451:
458: public void layoutContainer(Container c)
459: {
460: Dimension dims = frame.getSize();
461: Insets insets = frame.getInsets();
462:
463: dims.width -= insets.left + insets.right;
464: dims.height -= insets.top + insets.bottom;
465:
466: frame.getRootPane().getGlassPane().setBounds(0, 0, dims.width,
467: dims.height);
468: int nh = 0;
469: int sh = 0;
470: int ew = 0;
471: int ww = 0;
472:
473: if (northPane != null)
474: {
475: Dimension nDims = northPane.getPreferredSize();
476: nh = Math.min(nDims.height, dims.height);
477:
478: northPane.setBounds(insets.left, insets.top, dims.width, nh);
479: }
480:
481: if (southPane != null)
482: {
483: Dimension sDims = southPane.getPreferredSize();
484: sh = Math.min(sDims.height, dims.height - nh);
485:
486: southPane.setBounds(insets.left, insets.top + dims.height - sh,
487: dims.width, sh);
488: }
489:
490: int remHeight = dims.height - sh - nh;
491:
492: if (westPane != null)
493: {
494: Dimension wDims = westPane.getPreferredSize();
495: ww = Math.min(dims.width, wDims.width);
496:
497: westPane.setBounds(insets.left, insets.top + nh, ww, remHeight);
498: }
499:
500: if (eastPane != null)
501: {
502: Dimension eDims = eastPane.getPreferredSize();
503: ew = Math.min(eDims.width, dims.width - ww);
504:
505: eastPane.setBounds(insets.left + dims.width - ew, insets.top + nh,
506: ew, remHeight);
507: }
508:
509: int remWidth = dims.width - ww - ew;
510:
511: frame.getRootPane().setBounds(insets.left + ww, insets.top + nh,
512: remWidth, remHeight);
513: }
514:
515:
522: public Dimension minimumLayoutSize(Container c)
523: {
524: return getSize(c, true);
525: }
526:
527:
534: public Dimension maximumLayoutSize(Container c)
535: {
536: return preferredLayoutSize(c);
537: }
538:
539:
546: public Dimension preferredLayoutSize(Container c)
547: {
548: return getSize(c, false);
549: }
550:
551:
560: private Dimension getSize(Container c, boolean min)
561: {
562: Insets insets = frame.getInsets();
563:
564: Dimension contentDims = frame.getContentPane().getPreferredSize();
565: if (min)
566: contentDims.width = contentDims.height = 0;
567: int nWidth = 0;
568: int nHeight = 0;
569: int sWidth = 0;
570: int sHeight = 0;
571: int eWidth = 0;
572: int eHeight = 0;
573: int wWidth = 0;
574: int wHeight = 0;
575: Dimension dims;
576:
577: if (northPane != null)
578: {
579: dims = northPane.getPreferredSize();
580: if (dims != null)
581: {
582: nWidth = dims.width;
583: nHeight = dims.height;
584: }
585: }
586:
587: if (southPane != null)
588: {
589: dims = southPane.getPreferredSize();
590: if (dims != null)
591: {
592: sWidth = dims.width;
593: sHeight = dims.height;
594: }
595: }
596:
597: if (eastPane != null)
598: {
599: dims = eastPane.getPreferredSize();
600: if (dims != null)
601: {
602: sWidth = dims.width;
603: sHeight = dims.height;
604: }
605: }
606:
607: if (westPane != null)
608: {
609: dims = westPane.getPreferredSize();
610: if (dims != null)
611: {
612: wWidth = dims.width;
613: wHeight = dims.height;
614: }
615: }
616:
617: int width = Math.max(sWidth, nWidth);
618: width = Math.max(width, contentDims.width + eWidth + wWidth);
619:
620: int height = Math.max(eHeight, wHeight);
621: height = Math.max(height, contentDims.height);
622: height += nHeight + sHeight;
623:
624: width += insets.left + insets.right;
625: height += insets.top + insets.bottom;
626:
627: return new Dimension(width, height);
628: }
629:
630:
636: public void removeLayoutComponent(Component c)
637: {
638:
639: }
640: }
641:
642:
647: protected class GlassPaneDispatcher implements MouseInputListener
648: {
649:
650: private transient Component mouseEventTarget;
651:
652:
653: private transient Component pressedComponent;
654:
655:
656: private transient Component lastComponentEntered;
657:
658:
659: private transient Component tempComponent;
660:
661:
662: private transient int pressCount;
663:
664:
670: public void mouseEntered(MouseEvent e)
671: {
672: handleEvent(e);
673: }
674:
675:
681: public void mouseClicked(MouseEvent e)
682: {
683: handleEvent(e);
684: }
685:
686:
692: public void mouseDragged(MouseEvent e)
693: {
694: handleEvent(e);
695: }
696:
697:
703: public void mouseExited(MouseEvent e)
704: {
705: handleEvent(e);
706: }
707:
708:
714: public void mouseMoved(MouseEvent e)
715: {
716: handleEvent(e);
717: }
718:
719:
725: public void mousePressed(MouseEvent e)
726: {
727: activateFrame(frame);
728: handleEvent(e);
729: }
730:
731:
737: public void mouseReleased(MouseEvent e)
738: {
739: handleEvent(e);
740: }
741:
742:
748: private void acquireComponentForMouseEvent(MouseEvent me)
749: {
750: int x = me.getX();
751: int y = me.getY();
752:
753:
754: Component parent = frame.getContentPane();
755: if (parent == null)
756: return;
757: Component candidate = null;
758: Point p = me.getPoint();
759: while (candidate == null && parent != null)
760: {
761: candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
762: if (candidate == null)
763: {
764: p = SwingUtilities.convertPoint(parent, p.x, p.y,
765: parent.getParent());
766: parent = parent.getParent();
767: }
768: }
769:
770:
771:
772:
773: if (candidate == frame.getContentPane())
774: candidate = null;
775:
776:
777: if (lastComponentEntered != null && lastComponentEntered.isShowing()
778: && lastComponentEntered != candidate)
779: {
780: Point tp = SwingUtilities.convertPoint(frame.getContentPane(), x, y,
781: lastComponentEntered);
782: MouseEvent exited = new MouseEvent(lastComponentEntered,
783: MouseEvent.MOUSE_EXITED,
784: me.getWhen(), me.getModifiersEx(),
785: tp.x, tp.y, me.getClickCount(),
786: me.isPopupTrigger(),
787: me.getButton());
788: tempComponent = lastComponentEntered;
789: lastComponentEntered = null;
790: tempComponent.dispatchEvent(exited);
791: }
792:
793:
794: if (candidate != null)
795: {
796: mouseEventTarget = candidate;
797: if (candidate.isLightweight() && candidate.isShowing()
798: && candidate != frame.getContentPane()
799: && candidate != lastComponentEntered)
800: {
801: lastComponentEntered = mouseEventTarget;
802: Point cp = SwingUtilities.convertPoint(frame.getContentPane(), x,
803: y, lastComponentEntered);
804: MouseEvent entered = new MouseEvent(lastComponentEntered,
805: MouseEvent.MOUSE_ENTERED,
806: me.getWhen(),
807: me.getModifiersEx(), cp.x,
808: cp.y, me.getClickCount(),
809: me.isPopupTrigger(),
810: me.getButton());
811: lastComponentEntered.dispatchEvent(entered);
812: }
813: }
814:
815: if (me.getID() == MouseEvent.MOUSE_RELEASED
816: || me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
817: || me.getID() == MouseEvent.MOUSE_DRAGGED)
818:
819:
820:
821:
822:
823:
824: mouseEventTarget = pressedComponent;
825: else if (me.getID() == MouseEvent.MOUSE_CLICKED)
826: {
827:
828:
829: if (candidate != pressedComponent)
830: mouseEventTarget = null;
831: else if (pressCount == 0)
832: pressedComponent = null;
833: }
834: }
835:
836:
844: private void handleEvent(AWTEvent e)
845: {
846: if (e instanceof MouseEvent)
847: {
848: MouseEvent me = (MouseEvent) e;
849: acquireComponentForMouseEvent(me);
850:
851:
852: if (mouseEventTarget == null)
853: return;
854:
855:
856: if (mouseEventTarget.equals(frame.getGlassPane()))
857: return;
858:
859:
860: if (mouseEventTarget.isShowing()
861: && e.getID() != MouseEvent.MOUSE_ENTERED
862: && e.getID() != MouseEvent.MOUSE_EXITED)
863: {
864: MouseEvent newEvt = SwingUtilities.convertMouseEvent(
865: frame.getGlassPane(),
866: me,
867: mouseEventTarget);
868: mouseEventTarget.dispatchEvent(newEvt);
869:
870: switch (e.getID())
871: {
872: case MouseEvent.MOUSE_PRESSED:
873: if (pressCount++ == 0)
874: pressedComponent = mouseEventTarget;
875: break;
876: case MouseEvent.MOUSE_RELEASED:
877:
878:
879:
880: if (--pressCount == 0 && mouseEventTarget != pressedComponent)
881: pressedComponent = null;
882: break;
883: }
884: }
885: }
886: }
887: }
888:
889:
893: public class InternalFramePropertyChangeListener implements
894: PropertyChangeListener, VetoableChangeListener
895: {
896:
897:
903: public void vetoableChange(PropertyChangeEvent e)
904: throws PropertyVetoException
905: {
906: if (e.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))
907: {
908: if (frame.getDefaultCloseOperation() == JInternalFrame.HIDE_ON_CLOSE)
909: {
910: frame.setVisible(false);
911: frame.getDesktopPane().repaint();
912: throw new PropertyVetoException(
913: "close operation is HIDE_ON_CLOSE\n",
914: e);
915: }
916: else if (frame.getDefaultCloseOperation() == JInternalFrame.DISPOSE_ON_CLOSE)
917: closeFrame(frame);
918: else
919: throw new PropertyVetoException(
920: "close operation is DO_NOTHING_ON_CLOSE\n",
921: e);
922: }
923: }
924:
925:
931: public void propertyChange(PropertyChangeEvent evt)
932: {
933: if (evt.getPropertyName().equals(JInternalFrame.IS_MAXIMUM_PROPERTY))
934: {
935: if (frame.isMaximum())
936: maximizeFrame(frame);
937: else
938: minimizeFrame(frame);
939: }
940: else if (evt.getPropertyName().equals(JInternalFrame.IS_ICON_PROPERTY))
941: {
942: if (frame.isIcon())
943: iconifyFrame(frame);
944: else
945: deiconifyFrame(frame);
946: }
947: else if (evt.getPropertyName().equals(JInternalFrame.IS_SELECTED_PROPERTY))
948: {
949: if (frame.isSelected())
950: activateFrame(frame);
951: else
952: deactivateFrame(frame);
953: }
954: else if (evt.getPropertyName().equals(JInternalFrame.ROOT_PANE_PROPERTY)
955: || evt.getPropertyName().equals(
956: JInternalFrame.GLASS_PANE_PROPERTY))
957: {
958: Component old = (Component) evt.getOldValue();
959: old.removeMouseListener(glassPaneDispatcher);
960: old.removeMouseMotionListener(glassPaneDispatcher);
961:
962: Component newPane = (Component) evt.getNewValue();
963: newPane.addMouseListener(glassPaneDispatcher);
964: newPane.addMouseMotionListener(glassPaneDispatcher);
965:
966: frame.revalidate();
967: }
968:
976: }
977: }
978:
979:
982: private class InternalFrameBorder extends AbstractBorder implements
983: UIResource
984: {
985:
986: private static final int bSize = 5;
987:
988:
989: private static final int offset = 10;
990:
991:
996: public boolean isBorderOpaque()
997: {
998: return true;
999: }
1000:
1001:
1008: public Insets getBorderInsets(Component c)
1009: {
1010: return new Insets(bSize, bSize, bSize, bSize);
1011: }
1012:
1013:
1029: public void paintBorder(Component c, Graphics g, int x, int y, int width,
1030: int height)
1031: {
1032: g.translate(x, y);
1033: Color saved = g.getColor();
1034: Rectangle b = frame.getBounds();
1035:
1036: Color d = c.getBackground();
1037: g.setColor(d);
1038: g.fillRect(0, 0, bSize, b.height);
1039: g.fillRect(0, 0, b.width, bSize);
1040: g.fillRect(0, b.height - bSize, b.width, bSize);
1041: g.fillRect(b.width - bSize, 0, bSize, b.height);
1042:
1043: int x1 = 0;
1044: int x2 = bSize;
1045: int x3 = b.width - bSize;
1046: int x4 = b.width;
1047:
1048: int y1 = 0;
1049: int y2 = bSize;
1050: int y3 = b.height - bSize;
1051: int y4 = b.height;
1052:
1053: g.setColor(Color.GRAY);
1054: g.fillRect(0, 0, bSize, y4);
1055: g.fillRect(0, 0, x4, bSize);
1056: g.fillRect(0, y3, b.width, bSize);
1057: g.fillRect(x3, 0, bSize, b.height);
1058:
1059: g.fill3DRect(0, offset, bSize, b.height - 2 * offset, false);
1060: g.fill3DRect(offset, 0, b.width - 2 * offset, bSize, false);
1061: g.fill3DRect(offset, b.height - bSize, b.width - 2 * offset, bSize, false);
1062: g.fill3DRect(b.width - bSize, offset, bSize, b.height - 2 * offset, false);
1063:
1064: g.translate(-x, -y);
1065: g.setColor(saved);
1066: }
1067: }
1068:
1069:
1073: protected MouseInputAdapter borderListener;
1074:
1075:
1079: protected ComponentListener componentListener;
1080:
1081:
1085: protected MouseInputListener glassPaneDispatcher;
1086:
1087:
1091: protected PropertyChangeListener propertyChangeListener;
1092:
1093:
1098: private VetoableChangeListener internalFrameVetoableChangeListener;
1099:
1100:
1101: private transient BasicInternalFrameListener internalFrameListener;
1102:
1103:
1104: protected JComponent eastPane;
1105:
1106:
1107: protected JComponent northPane;
1108:
1109:
1110: protected JComponent southPane;
1111:
1112:
1113: protected JComponent westPane;
1114:
1115:
1119: protected KeyStroke openMenuKey;
1120:
1121:
1122: protected BasicInternalFrameTitlePane titlePane;
1123:
1124:
1125: protected JInternalFrame frame;
1126:
1127:
1128: protected LayoutManager internalFrameLayout;
1129:
1130:
1131: private transient JDesktopPane desktopPane;
1132:
1133:
1138: public BasicInternalFrameUI(JInternalFrame b)
1139: {
1140:
1141: }
1142:
1143:
1151: public static ComponentUI createUI(JComponent b)
1152: {
1153: return new BasicInternalFrameUI((JInternalFrame) b);
1154: }
1155:
1156:
1161: public void installUI(JComponent c)
1162: {
1163: if (c instanceof JInternalFrame)
1164: {
1165: frame = (JInternalFrame) c;
1166:
1167: internalFrameLayout = createLayoutManager();
1168: frame.setLayout(internalFrameLayout);
1169:
1170: ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(false);
1171: frame.getRootPane().getGlassPane().setVisible(true);
1172:
1173: installDefaults();
1174: installListeners();
1175: installComponents();
1176: installKeyboardActions();
1177:
1178: frame.setOpaque(true);
1179: frame.invalidate();
1180: }
1181: }
1182:
1183:
1188: public void uninstallUI(JComponent c)
1189: {
1190: uninstallKeyboardActions();
1191: uninstallComponents();
1192: uninstallListeners();
1193: uninstallDefaults();
1194:
1195: frame.setLayout(null);
1196: ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(true);
1197: frame.getRootPane().getGlassPane().setVisible(false);
1198:
1199: frame = null;
1200: }
1201:
1202:
1205: protected void installDefaults()
1206: {
1207: LookAndFeel.installBorder(frame, "InternalFrame.border");
1208: frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
1209:
1210: frame.setVisible(false);
1211: }
1212:
1213:
1216: protected void installKeyboardActions()
1217: {
1218:
1219: }
1220:
1221:
1224: protected void installComponents()
1225: {
1226: setNorthPane(createNorthPane(frame));
1227: setSouthPane(createSouthPane(frame));
1228: setEastPane(createEastPane(frame));
1229: setWestPane(createWestPane(frame));
1230: }
1231:
1232:
1235: protected void installListeners()
1236: {
1237: glassPaneDispatcher = createGlassPaneDispatcher();
1238: createInternalFrameListener();
1239: borderListener = createBorderListener(frame);
1240: componentListener = createComponentListener();
1241: propertyChangeListener = createPropertyChangeListener();
1242: internalFrameVetoableChangeListener = new InternalFramePropertyChangeListener();
1243:
1244: frame.addMouseListener(borderListener);
1245: frame.addMouseMotionListener(borderListener);
1246: frame.addInternalFrameListener(internalFrameListener);
1247: frame.addPropertyChangeListener(propertyChangeListener);
1248: frame.addVetoableChangeListener(internalFrameVetoableChangeListener);
1249: frame.getRootPane().getGlassPane().addMouseListener(glassPaneDispatcher);
1250: frame.getRootPane().getGlassPane().addMouseMotionListener(glassPaneDispatcher);
1251: }
1252:
1253:
1256: protected void uninstallDefaults()
1257: {
1258: frame.setBorder(null);
1259: }
1260:
1261:
1264: protected void uninstallComponents()
1265: {
1266: setNorthPane(null);
1267: setSouthPane(null);
1268: setEastPane(null);
1269: setWestPane(null);
1270: }
1271:
1272:
1275: protected void uninstallListeners()
1276: {
1277: if (desktopPane != null)
1278: desktopPane.removeComponentListener(componentListener);
1279:
1280: frame.getRootPane().getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
1281: frame.getRootPane().getGlassPane().removeMouseListener(glassPaneDispatcher);
1282:
1283: frame.removePropertyChangeListener(propertyChangeListener);
1284: frame.removeInternalFrameListener(internalFrameListener);
1285: frame.removeMouseMotionListener(borderListener);
1286: frame.removeMouseListener(borderListener);
1287:
1288: propertyChangeListener = null;
1289: componentListener = null;
1290: borderListener = null;
1291: internalFrameListener = null;
1292: glassPaneDispatcher = null;
1293: }
1294:
1295:
1298: protected void uninstallKeyboardActions()
1299: {
1300:
1301: }
1302:
1303:
1308: protected LayoutManager createLayoutManager()
1309: {
1310: return new InternalFrameLayout();
1311: }
1312:
1313:
1318: protected PropertyChangeListener createPropertyChangeListener()
1319: {
1320: return new InternalFramePropertyChangeListener();
1321: }
1322:
1323:
1330: public Dimension getPreferredSize(JComponent x)
1331: {
1332: return internalFrameLayout.preferredLayoutSize(x);
1333: }
1334:
1335:
1342: public Dimension getMinimumSize(JComponent x)
1343: {
1344: return internalFrameLayout.minimumLayoutSize(x);
1345: }
1346:
1347:
1354: public Dimension getMaximumSize(JComponent x)
1355: {
1356: return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
1357: }
1358:
1359:
1367: protected void replacePane(JComponent currentPane, JComponent newPane)
1368: {
1369: if (currentPane != null)
1370: {
1371: deinstallMouseHandlers(currentPane);
1372: frame.remove(currentPane);
1373: }
1374:
1375: if (newPane != null)
1376: {
1377: installMouseHandlers(newPane);
1378: frame.add(newPane);
1379: }
1380: }
1381:
1382:
1388: protected void deinstallMouseHandlers(JComponent c)
1389: {
1390: c.removeMouseListener(borderListener);
1391: c.removeMouseMotionListener(borderListener);
1392: }
1393:
1394:
1400: protected void installMouseHandlers(JComponent c)
1401: {
1402: c.addMouseListener(borderListener);
1403: c.addMouseMotionListener(borderListener);
1404: }
1405:
1406:
1413: protected JComponent createNorthPane(JInternalFrame w)
1414: {
1415: titlePane = new BasicInternalFrameTitlePane(w);
1416: return titlePane;
1417: }
1418:
1419:
1426: protected JComponent createWestPane(JInternalFrame w)
1427: {
1428: return null;
1429: }
1430:
1431:
1438: protected JComponent createSouthPane(JInternalFrame w)
1439: {
1440: return null;
1441: }
1442:
1443:
1450: protected JComponent createEastPane(JInternalFrame w)
1451: {
1452: return null;
1453: }
1454:
1455:
1462: protected MouseInputAdapter createBorderListener(JInternalFrame w)
1463: {
1464: return new BorderListener();
1465: }
1466:
1467:
1470: protected void createInternalFrameListener()
1471: {
1472: internalFrameListener = new BasicInternalFrameListener();
1473: }
1474:
1475:
1480: protected final boolean isKeyBindingRegistered()
1481: {
1482:
1483: return false;
1484: }
1485:
1486:
1491: protected final void setKeyBindingRegistered(boolean b)
1492: {
1493:
1494: }
1495:
1496:
1501: public final boolean isKeyBindingActive()
1502: {
1503:
1504: return false;
1505: }
1506:
1507:
1512: protected final void setKeyBindingActive(boolean b)
1513: {
1514:
1515: }
1516:
1517:
1520: protected void setupMenuOpenKey()
1521: {
1522:
1523: }
1524:
1525:
1528: protected void setupMenuCloseKey()
1529: {
1530:
1531: }
1532:
1533:
1538: public JComponent getNorthPane()
1539: {
1540: return northPane;
1541: }
1542:
1543:
1548: public void setNorthPane(JComponent c)
1549: {
1550: replacePane(northPane, c);
1551: northPane = c;
1552: }
1553:
1554:
1559: public JComponent getSouthPane()
1560: {
1561: return southPane;
1562: }
1563:
1564:
1569: public void setSouthPane(JComponent c)
1570: {
1571: replacePane(southPane, c);
1572: southPane = c;
1573: }
1574:
1575:
1580: public void setEastPane(JComponent c)
1581: {
1582: replacePane(eastPane, c);
1583: eastPane = c;
1584: }
1585:
1586:
1591: public JComponent getEastPane()
1592: {
1593: return eastPane;
1594: }
1595:
1596:
1601: public void setWestPane(JComponent c)
1602: {
1603: replacePane(westPane, c);
1604: westPane = c;
1605: }
1606:
1607:
1612: public JComponent getWestPane()
1613: {
1614: return westPane;
1615: }
1616:
1617:
1622: protected DesktopManager getDesktopManager()
1623: {
1624: DesktopManager value = null;
1625: JDesktopPane pane = frame.getDesktopPane();
1626: if (pane != null)
1627: value = frame.getDesktopPane().getDesktopManager();
1628: if (value == null)
1629: value = createDesktopManager();
1630: return value;
1631: }
1632:
1633:
1640: protected DesktopManager createDesktopManager()
1641: {
1642: return new DefaultDesktopManager();
1643: }
1644:
1645:
1650: protected void closeFrame(JInternalFrame f)
1651: {
1652: getDesktopManager().closeFrame(f);
1653: }
1654:
1655:
1660: protected void maximizeFrame(JInternalFrame f)
1661: {
1662: getDesktopManager().maximizeFrame(f);
1663: }
1664:
1665:
1670: protected void minimizeFrame(JInternalFrame f)
1671: {
1672: getDesktopManager().minimizeFrame(f);
1673: }
1674:
1675:
1680: protected void iconifyFrame(JInternalFrame f)
1681: {
1682: getDesktopManager().iconifyFrame(f);
1683: }
1684:
1685:
1690: protected void deiconifyFrame(JInternalFrame f)
1691: {
1692: getDesktopManager().deiconifyFrame(f);
1693: }
1694:
1695:
1700: protected void activateFrame(JInternalFrame f)
1701: {
1702: getDesktopManager().activateFrame(f);
1703: }
1704:
1705:
1710: protected void deactivateFrame(JInternalFrame f)
1711: {
1712: getDesktopManager().deactivateFrame(f);
1713: }
1714:
1715:
1720: protected ComponentListener createComponentListener()
1721: {
1722: return new ComponentHandler();
1723: }
1724:
1725:
1730: protected MouseInputListener createGlassPaneDispatcher()
1731: {
1732: return new GlassPaneDispatcher();
1733: }
1734: }