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: import ;
78: import ;
79: import ;
80:
81:
84: public class BasicInternalFrameUI extends InternalFrameUI
85: {
86:
90: protected class BasicInternalFrameListener implements InternalFrameListener
91: {
92:
97: public void internalFrameActivated(InternalFrameEvent e)
98: {
99:
100: }
101:
102:
107: public void internalFrameClosed(InternalFrameEvent e)
108: {
109:
110: }
111:
112:
117: public void internalFrameClosing(InternalFrameEvent e)
118: {
119:
120: }
121:
122:
127: public void internalFrameDeactivated(InternalFrameEvent e)
128: {
129:
130: }
131:
132:
137: public void internalFrameDeiconified(InternalFrameEvent e)
138: {
139:
140: }
141:
142:
147: public void internalFrameIconified(InternalFrameEvent e)
148: {
149:
150: }
151:
152:
157: public void internalFrameOpened(InternalFrameEvent e)
158: {
159:
160: }
161: }
162:
163:
168: protected class BorderListener extends MouseInputAdapter
169: implements SwingConstants
170: {
171:
172: protected final int RESIZE_NONE = 0;
173:
174:
175: private transient int xOffset = 0;
176:
177:
178: private transient int yOffset = 0;
179:
180:
181: private transient int direction = -1;
182:
183:
184: private transient Rectangle cacheRect = new Rectangle();
185:
186:
191: public void mouseClicked(MouseEvent e)
192: {
193:
194:
195: }
196:
197:
203: public void mouseDragged(MouseEvent e)
204: {
205:
206:
207: if (frame.isMaximum())
208: return;
209: DesktopManager dm = getDesktopManager();
210: Rectangle b = frame.getBounds();
211: Dimension min = frame.getMinimumSize();
212: if (min == null)
213: min = new Dimension(0, 0);
214: Insets insets = frame.getInsets();
215: int x = e.getX();
216: int y = e.getY();
217: if (e.getSource() == frame && frame.isResizable())
218: {
219: switch (direction)
220: {
221: case NORTH:
222: cacheRect.setBounds(b.x,
223: Math.min(b.y + y, b.y + b.height
224: - min.height), b.width, b.height
225: - y);
226: break;
227: case NORTH_EAST:
228: cacheRect.setBounds(b.x,
229: Math.min(b.y + y, b.y + b.height
230: - min.height), x, b.height - y);
231: break;
232: case EAST:
233: cacheRect.setBounds(b.x, b.y, x, b.height);
234: break;
235: case SOUTH_EAST:
236: cacheRect.setBounds(b.x, b.y, x, y);
237: break;
238: case SOUTH:
239: cacheRect.setBounds(b.x, b.y, b.width, y);
240: break;
241: case SOUTH_WEST:
242: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
243: b.y, b.width - x, y);
244: break;
245: case WEST:
246: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
247: b.y, b.width - x, b.height);
248: break;
249: case NORTH_WEST:
250: cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
251: Math.min(b.y + y, b.y + b.height
252: - min.height), b.width - x,
253: b.height - y);
254: break;
255: }
256: dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
257: Math.max(min.width, cacheRect.width),
258: Math.max(min.height, cacheRect.height));
259: }
260: else if (e.getSource() == titlePane)
261: {
262: Rectangle fBounds = frame.getBounds();
263:
264: dm.dragFrame(frame, e.getX() - xOffset + b.x,
265: e.getY() - yOffset + b.y);
266: }
267: }
268:
269:
274: public void mouseExited(MouseEvent e)
275: {
276:
277:
278: }
279:
280:
286: public void mouseMoved(MouseEvent e)
287: {
288:
289:
290: }
291:
292:
297: public void mousePressed(MouseEvent e)
298: {
299: activateFrame(frame);
300: DesktopManager dm = getDesktopManager();
301: int x = e.getX();
302: int y = e.getY();
303: Insets insets = frame.getInsets();
304:
305: if (e.getSource() == frame && frame.isResizable())
306: {
307: direction = sectionOfClick(x, y);
308: dm.beginResizingFrame(frame, direction);
309: }
310: else if (e.getSource() == titlePane)
311: {
312: Rectangle tBounds = titlePane.getBounds();
313:
314: xOffset = e.getX() - tBounds.x + insets.left;
315: yOffset = e.getY() - tBounds.y + insets.top;
316:
317: dm.beginDraggingFrame(frame);
318: }
319: }
320:
321:
326: public void mouseReleased(MouseEvent e)
327: {
328: DesktopManager dm = getDesktopManager();
329: xOffset = 0;
330: yOffset = 0;
331: if (e.getSource() == frame && frame.isResizable())
332: dm.endResizingFrame(frame);
333: else if (e.getSource() == titlePane)
334: dm.endDraggingFrame(frame);
335: }
336:
337:
346: private int sectionOfClick(int x, int y)
347: {
348: Insets insets = frame.getInsets();
349: Rectangle b = frame.getBounds();
350: if (x < insets.left && y < insets.top)
351: return NORTH_WEST;
352: else if (x > b.width - insets.right && y < insets.top)
353: return NORTH_EAST;
354: else if (x > b.width - insets.right && y > b.height - insets.bottom)
355: return SOUTH_EAST;
356: else if (x < insets.left && y > b.height - insets.bottom)
357: return SOUTH_WEST;
358: else if (y < insets.top)
359: return NORTH;
360: else if (x < insets.left)
361: return WEST;
362: else if (y > b.height - insets.bottom)
363: return SOUTH;
364: else if (x > b.width - insets.right)
365: return EAST;
366:
367: return -1;
368: }
369: }
370:
371:
376: protected class ComponentHandler implements ComponentListener
377: {
378:
383: public void componentHidden(ComponentEvent e)
384: {
385:
386: }
387:
388:
393: public void componentMoved(ComponentEvent e)
394: {
395:
396: }
397:
398:
403: public void componentResized(ComponentEvent e)
404: {
405: if (frame.isMaximum())
406: {
407: JDesktopPane pane = (JDesktopPane) e.getSource();
408: Insets insets = pane.getInsets();
409: Rectangle bounds = pane.getBounds();
410:
411: frame.setBounds(bounds.x + insets.left, bounds.y + insets.top,
412: bounds.width - insets.left - insets.right,
413: bounds.height - insets.top - insets.bottom);
414: frame.revalidate();
415: frame.repaint();
416: }
417:
418:
419: }
420:
421:
426: public void componentShown(ComponentEvent e)
427: {
428:
429: }
430: }
431:
432:
435: public class InternalFrameLayout implements LayoutManager
436: {
437:
444: public void addLayoutComponent(String name, Component c)
445: {
446: }
447:
448:
454: public void layoutContainer(Container c)
455: {
456: Dimension dims = frame.getSize();
457: Insets insets = frame.getInsets();
458:
459: dims.width -= insets.left + insets.right;
460: dims.height -= insets.top + insets.bottom;
461:
462: frame.getRootPane().getGlassPane().setBounds(0, 0, dims.width,
463: dims.height);
464: int nh = 0;
465: int sh = 0;
466: int ew = 0;
467: int ww = 0;
468:
469: if (northPane != null)
470: {
471: Dimension nDims = northPane.getPreferredSize();
472: nh = Math.min(nDims.height, dims.height);
473:
474: northPane.setBounds(insets.left, insets.top, dims.width, nh);
475: }
476:
477: if (southPane != null)
478: {
479: Dimension sDims = southPane.getPreferredSize();
480: sh = Math.min(sDims.height, dims.height - nh);
481:
482: southPane.setBounds(insets.left, insets.top + dims.height - sh,
483: dims.width, sh);
484: }
485:
486: int remHeight = dims.height - sh - nh;
487:
488: if (westPane != null)
489: {
490: Dimension wDims = westPane.getPreferredSize();
491: ww = Math.min(dims.width, wDims.width);
492:
493: westPane.setBounds(insets.left, insets.top + nh, ww, remHeight);
494: }
495:
496: if (eastPane != null)
497: {
498: Dimension eDims = eastPane.getPreferredSize();
499: ew = Math.min(eDims.width, dims.width - ww);
500:
501: eastPane.setBounds(insets.left + dims.width - ew, insets.top + nh,
502: ew, remHeight);
503: }
504:
505: int remWidth = dims.width - ww - ew;
506:
507: frame.getRootPane().setBounds(insets.left + ww, insets.top + nh,
508: remWidth, remHeight);
509: }
510:
511:
518: public Dimension minimumLayoutSize(Container c)
519: {
520: return getSize(c, true);
521: }
522:
523:
530: public Dimension maximumLayoutSize(Container c)
531: {
532: return preferredLayoutSize(c);
533: }
534:
535:
542: public Dimension preferredLayoutSize(Container c)
543: {
544: return getSize(c, false);
545: }
546:
547:
555: private Dimension getSize(Container c, boolean min)
556: {
557: Insets insets = frame.getInsets();
558:
559: Dimension contentDims = frame.getContentPane().getPreferredSize();
560: if (min)
561: contentDims.width = contentDims.height = 0;
562: int nWidth = 0;
563: int nHeight = 0;
564: int sWidth = 0;
565: int sHeight = 0;
566: int eWidth = 0;
567: int eHeight = 0;
568: int wWidth = 0;
569: int wHeight = 0;
570: Dimension dims;
571:
572: if (northPane != null)
573: {
574: dims = northPane.getPreferredSize();
575: if (dims != null)
576: {
577: nWidth = dims.width;
578: nHeight = dims.height;
579: }
580: }
581:
582: if (southPane != null)
583: {
584: dims = southPane.getPreferredSize();
585: if (dims != null)
586: {
587: sWidth = dims.width;
588: sHeight = dims.height;
589: }
590: }
591:
592: if (eastPane != null)
593: {
594: dims = eastPane.getPreferredSize();
595: if (dims != null)
596: {
597: sWidth = dims.width;
598: sHeight = dims.height;
599: }
600: }
601:
602: if (westPane != null)
603: {
604: dims = westPane.getPreferredSize();
605: if (dims != null)
606: {
607: wWidth = dims.width;
608: wHeight = dims.height;
609: }
610: }
611:
612: int width = Math.max(sWidth, nWidth);
613: width = Math.max(width, contentDims.width + eWidth + wWidth);
614:
615: int height = Math.max(eHeight, wHeight);
616: height = Math.max(height, contentDims.height);
617: height += nHeight + sHeight;
618:
619: width += insets.left + insets.right;
620: height += insets.top + insets.bottom;
621:
622: return new Dimension(width, height);
623: }
624:
625:
631: public void removeLayoutComponent(Component c)
632: {
633: }
634: }
635:
636:
641: protected class GlassPaneDispatcher implements MouseInputListener
642: {
643:
644: private transient Component mouseEventTarget;
645:
646:
647: private transient Component pressedComponent;
648:
649:
650: private transient Component lastComponentEntered;
651:
652:
653: private transient Component tempComponent;
654:
655:
656: private transient int pressCount;
657:
658:
663: public void mouseEntered(MouseEvent e)
664: {
665: handleEvent(e);
666: }
667:
668:
673: public void mouseClicked(MouseEvent e)
674: {
675: handleEvent(e);
676: }
677:
678:
683: public void mouseDragged(MouseEvent e)
684: {
685: handleEvent(e);
686: }
687:
688:
693: public void mouseExited(MouseEvent e)
694: {
695: handleEvent(e);
696: }
697:
698:
703: public void mouseMoved(MouseEvent e)
704: {
705: handleEvent(e);
706: }
707:
708:
713: public void mousePressed(MouseEvent e)
714: {
715: activateFrame(frame);
716: handleEvent(e);
717: }
718:
719:
724: public void mouseReleased(MouseEvent e)
725: {
726: handleEvent(e);
727: }
728:
729:
735: private void acquireComponentForMouseEvent(MouseEvent me)
736: {
737: int x = me.getX();
738: int y = me.getY();
739:
740:
741: Component parent = frame.getContentPane();
742: if (parent == null)
743: return;
744: Component candidate = null;
745: Point p = me.getPoint();
746: while (candidate == null && parent != null)
747: {
748: candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
749: if (candidate == null)
750: {
751: p = SwingUtilities.convertPoint(parent, p.x, p.y,
752: parent.getParent());
753: parent = parent.getParent();
754: }
755: }
756:
757:
758:
759:
760: if (candidate == frame.getContentPane())
761: candidate = null;
762:
763:
764: if (lastComponentEntered != null && lastComponentEntered.isShowing()
765: && lastComponentEntered != candidate)
766: {
767: Point tp = SwingUtilities.convertPoint(frame.getContentPane(), x, y,
768: lastComponentEntered);
769: MouseEvent exited = new MouseEvent(lastComponentEntered,
770: MouseEvent.MOUSE_EXITED,
771: me.getWhen(), me.getModifiersEx(),
772: tp.x, tp.y, me.getClickCount(),
773: me.isPopupTrigger(),
774: me.getButton());
775: tempComponent = lastComponentEntered;
776: lastComponentEntered = null;
777: tempComponent.dispatchEvent(exited);
778: }
779:
780:
781: if (candidate != null)
782: {
783: mouseEventTarget = candidate;
784: if (candidate.isLightweight() && candidate.isShowing()
785: && candidate != frame.getContentPane()
786: && candidate != lastComponentEntered)
787: {
788: lastComponentEntered = mouseEventTarget;
789: Point cp = SwingUtilities.convertPoint(frame.getContentPane(),
790: x, y, lastComponentEntered);
791: MouseEvent entered = new MouseEvent(lastComponentEntered,
792: MouseEvent.MOUSE_ENTERED,
793: me.getWhen(),
794: me.getModifiersEx(), cp.x,
795: cp.y, me.getClickCount(),
796: me.isPopupTrigger(),
797: me.getButton());
798: lastComponentEntered.dispatchEvent(entered);
799: }
800: }
801:
802: if (me.getID() == MouseEvent.MOUSE_RELEASED
803: || me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
804: || me.getID() == MouseEvent.MOUSE_DRAGGED)
805:
806:
807:
808:
809:
810:
811: mouseEventTarget = pressedComponent;
812: else if (me.getID() == MouseEvent.MOUSE_CLICKED)
813: {
814:
815:
816: if (candidate != pressedComponent)
817: mouseEventTarget = null;
818: else if (pressCount == 0)
819: pressedComponent = null;
820: }
821: }
822:
823:
830: private void handleEvent(AWTEvent e)
831: {
832: if (e instanceof MouseEvent)
833: {
834: MouseEvent me = SwingUtilities.convertMouseEvent(frame.getRootPane()
835: .getGlassPane(),
836: (MouseEvent) e,
837: frame.getRootPane()
838: .getGlassPane());
839:
840: acquireComponentForMouseEvent(me);
841:
842:
843: if (mouseEventTarget != null && mouseEventTarget.isShowing()
844: && e.getID() != MouseEvent.MOUSE_ENTERED
845: && e.getID() != MouseEvent.MOUSE_EXITED)
846: {
847: MouseEvent newEvt = SwingUtilities.convertMouseEvent(frame
848: .getContentPane(),
849: me,
850: mouseEventTarget);
851: mouseEventTarget.dispatchEvent(newEvt);
852:
853: switch (e.getID())
854: {
855: case MouseEvent.MOUSE_PRESSED:
856: if (pressCount++ == 0)
857: pressedComponent = mouseEventTarget;
858: break;
859: case MouseEvent.MOUSE_RELEASED:
860:
861:
862:
863: if (--pressCount == 0
864: && mouseEventTarget != pressedComponent)
865: pressedComponent = null;
866: break;
867: }
868: }
869: }
870: }
871: }
872:
873:
877: public class InternalFramePropertyChangeListener
878: implements PropertyChangeListener, VetoableChangeListener
879: {
880:
881:
887: public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
888: {
889: if (e.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))
890: {
891: if (frame.getDefaultCloseOperation() == JInternalFrame.HIDE_ON_CLOSE)
892: {
893: frame.setVisible(false);
894: frame.getDesktopPane().repaint();
895: throw new PropertyVetoException ("close operation is HIDE_ON_CLOSE\n", e);
896: }
897: else if (frame.getDefaultCloseOperation() == JInternalFrame.DISPOSE_ON_CLOSE)
898: closeFrame(frame);
899: else
900: throw new PropertyVetoException ("close operation is DO_NOTHING_ON_CLOSE\n", e);
901: }
902: }
903:
904:
910: public void propertyChange(PropertyChangeEvent evt)
911: {
912: if (evt.getPropertyName().equals(JInternalFrame.IS_MAXIMUM_PROPERTY))
913: {
914: if (frame.isMaximum())
915: maximizeFrame(frame);
916: else
917: minimizeFrame(frame);
918: }
919: else if (evt.getPropertyName().equals(JInternalFrame.IS_ICON_PROPERTY))
920: {
921: if (frame.isIcon())
922: iconifyFrame(frame);
923: else
924: deiconifyFrame(frame);
925: }
926: else if (evt.getPropertyName().equals(JInternalFrame.IS_SELECTED_PROPERTY))
927: {
928: if (frame.isSelected())
929: activateFrame(frame);
930: else
931: getDesktopManager().deactivateFrame(frame);
932: }
933: else if (evt.getPropertyName().equals(JInternalFrame.ROOT_PANE_PROPERTY)
934: || evt.getPropertyName().equals(JInternalFrame.GLASS_PANE_PROPERTY))
935: {
936: Component old = (Component) evt.getOldValue();
937: old.removeMouseListener(glassPaneDispatcher);
938: old.removeMouseMotionListener(glassPaneDispatcher);
939:
940: Component newPane = (Component) evt.getNewValue();
941: newPane.addMouseListener(glassPaneDispatcher);
942: newPane.addMouseMotionListener(glassPaneDispatcher);
943:
944: frame.revalidate();
945: }
946:
956: }
957: }
958:
959:
962: private class InternalFrameBorder extends AbstractBorder
963: implements UIResource
964: {
965:
966: private static final int bSize = 5;
967:
968:
969: private static final int offset = 10;
970:
971:
976: public boolean isBorderOpaque()
977: {
978: return true;
979: }
980:
981:
988: public Insets getBorderInsets(Component c)
989: {
990: return new Insets(bSize, bSize, bSize, bSize);
991: }
992:
993:
1003: public void paintBorder(Component c, Graphics g, int x, int y, int width,
1004: int height)
1005: {
1006: g.translate(x, y);
1007: Color saved = g.getColor();
1008: Rectangle b = frame.getBounds();
1009:
1010: Color d = c.getBackground();
1011: g.setColor(d);
1012: g.fillRect(0, 0, bSize, b.height);
1013: g.fillRect(0, 0, b.width, bSize);
1014: g.fillRect(0, b.height - bSize, b.width, bSize);
1015: g.fillRect(b.width - bSize, 0, bSize, b.height);
1016:
1017: int x1 = 0;
1018: int x2 = bSize;
1019: int x3 = b.width - bSize;
1020: int x4 = b.width;
1021:
1022: int y1 = 0;
1023: int y2 = bSize;
1024: int y3 = b.height - bSize;
1025: int y4 = b.height;
1026:
1027: g.setColor(Color.GRAY);
1028: g.fillRect(0, 0, bSize, y4);
1029: g.fillRect(0, 0, x4, bSize);
1030: g.fillRect(0, y3, b.width, bSize);
1031: g.fillRect(x3, 0, bSize, b.height);
1032:
1033: g.fill3DRect(0, offset, bSize, b.height - 2 * offset, false);
1034: g.fill3DRect(offset, 0, b.width - 2 * offset, bSize, false);
1035: g.fill3DRect(offset, b.height - bSize, b.width - 2 * offset, bSize, false);
1036: g.fill3DRect(b.width - bSize, offset, bSize, b.height - 2 * offset, false);
1037:
1038: g.translate(-x, -y);
1039: g.setColor(saved);
1040: }
1041: }
1042:
1043:
1047: protected MouseInputAdapter borderListener;
1048:
1049:
1053: protected ComponentListener componentListener;
1054:
1055:
1059: protected MouseInputListener glassPaneDispatcher;
1060:
1061:
1065: protected PropertyChangeListener propertyChangeListener;
1066:
1067:
1072: private VetoableChangeListener internalFrameVetoableChangeListener;
1073:
1074:
1075: private transient BasicInternalFrameListener internalFrameListener;
1076:
1077:
1078: protected JComponent eastPane;
1079:
1080:
1081: protected JComponent northPane;
1082:
1083:
1084: protected JComponent southPane;
1085:
1086:
1087: protected JComponent westPane;
1088:
1089:
1093: protected KeyStroke openMenuKey;
1094:
1095:
1096: protected BasicInternalFrameTitlePane titlePane;
1097:
1098:
1099: protected JInternalFrame frame;
1100:
1101:
1102: protected LayoutManager internalFrameLayout;
1103:
1104:
1105: private transient JDesktopPane desktopPane;
1106:
1107:
1112: public BasicInternalFrameUI(JInternalFrame b)
1113: {
1114: }
1115:
1116:
1124: public static ComponentUI createUI(JComponent b)
1125: {
1126: return new BasicInternalFrameUI((JInternalFrame) b);
1127: }
1128:
1129:
1134: public void installUI(JComponent c)
1135: {
1136: if (c instanceof JInternalFrame)
1137: {
1138: frame = (JInternalFrame) c;
1139:
1140: internalFrameLayout = createLayoutManager();
1141: frame.setLayout(internalFrameLayout);
1142:
1143: ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(false);
1144: frame.getRootPane().getGlassPane().setVisible(true);
1145:
1146: installDefaults();
1147: installListeners();
1148: installComponents();
1149: installKeyboardActions();
1150:
1151: frame.setOpaque(true);
1152: frame.invalidate();
1153: }
1154: }
1155:
1156:
1161: public void uninstallUI(JComponent c)
1162: {
1163: uninstallKeyboardActions();
1164: uninstallComponents();
1165: uninstallListeners();
1166: uninstallDefaults();
1167:
1168: frame.setLayout(null);
1169: ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(true);
1170: frame.getRootPane().getGlassPane().setVisible(false);
1171:
1172: frame = null;
1173: }
1174:
1175:
1178: protected void installDefaults()
1179: {
1180: UIDefaults defaults = UIManager.getLookAndFeelDefaults();
1181: Border border = defaults.getBorder("InternalFrame.border");
1182: frame.setBorder(border);
1183: frame.setFrameIcon(defaults.getIcon("InternalFrame.icon"));
1184:
1185: frame.setVisible(false);
1186: }
1187:
1188:
1191: protected void installKeyboardActions()
1192: {
1193:
1194: }
1195:
1196:
1199: protected void installComponents()
1200: {
1201: setNorthPane(createNorthPane(frame));
1202: setSouthPane(createSouthPane(frame));
1203: setEastPane(createEastPane(frame));
1204: setWestPane(createWestPane(frame));
1205: }
1206:
1207:
1210: protected void installListeners()
1211: {
1212: glassPaneDispatcher = createGlassPaneDispatcher();
1213: createInternalFrameListener();
1214: borderListener = createBorderListener(frame);
1215: componentListener = createComponentListener();
1216: propertyChangeListener = createPropertyChangeListener();
1217: internalFrameVetoableChangeListener = new InternalFramePropertyChangeListener();
1218:
1219: frame.addMouseListener(borderListener);
1220: frame.addMouseMotionListener(borderListener);
1221: frame.addInternalFrameListener(internalFrameListener);
1222: frame.addPropertyChangeListener(propertyChangeListener);
1223: frame.addVetoableChangeListener(internalFrameVetoableChangeListener);
1224: frame.getRootPane().getGlassPane().addMouseListener(glassPaneDispatcher);
1225: frame.getRootPane().getGlassPane().addMouseMotionListener(glassPaneDispatcher);
1226: }
1227:
1228:
1231: protected void uninstallDefaults()
1232: {
1233: frame.setBorder(null);
1234: }
1235:
1236:
1239: protected void uninstallComponents()
1240: {
1241: setNorthPane(null);
1242: setSouthPane(null);
1243: setEastPane(null);
1244: setWestPane(null);
1245: }
1246:
1247:
1250: protected void uninstallListeners()
1251: {
1252: if (desktopPane != null)
1253: desktopPane.removeComponentListener(componentListener);
1254:
1255: frame.getRootPane().getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
1256: frame.getRootPane().getGlassPane().removeMouseListener(glassPaneDispatcher);
1257:
1258: frame.removePropertyChangeListener(propertyChangeListener);
1259: frame.removeInternalFrameListener(internalFrameListener);
1260: frame.removeMouseMotionListener(borderListener);
1261: frame.removeMouseListener(borderListener);
1262:
1263: propertyChangeListener = null;
1264: componentListener = null;
1265: borderListener = null;
1266: internalFrameListener = null;
1267: glassPaneDispatcher = null;
1268: }
1269:
1270:
1273: protected void uninstallKeyboardActions()
1274: {
1275:
1276: }
1277:
1278:
1283: protected LayoutManager createLayoutManager()
1284: {
1285: return new InternalFrameLayout();
1286: }
1287:
1288:
1293: protected PropertyChangeListener createPropertyChangeListener()
1294: {
1295: return new InternalFramePropertyChangeListener();
1296: }
1297:
1298:
1305: public Dimension getPreferredSize(JComponent x)
1306: {
1307: return internalFrameLayout.preferredLayoutSize(x);
1308: }
1309:
1310:
1317: public Dimension getMinimumSize(JComponent x)
1318: {
1319: return internalFrameLayout.minimumLayoutSize(x);
1320: }
1321:
1322:
1329: public Dimension getMaximumSize(JComponent x)
1330: {
1331: return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
1332: }
1333:
1334:
1342: protected void replacePane(JComponent currentPane, JComponent newPane)
1343: {
1344: if (currentPane != null)
1345: {
1346: deinstallMouseHandlers(currentPane);
1347: frame.remove(currentPane);
1348: }
1349:
1350: if (newPane != null)
1351: {
1352: installMouseHandlers(newPane);
1353: frame.add(newPane);
1354: }
1355: }
1356:
1357:
1363: protected void deinstallMouseHandlers(JComponent c)
1364: {
1365: c.removeMouseListener(borderListener);
1366: c.removeMouseMotionListener(borderListener);
1367: }
1368:
1369:
1375: protected void installMouseHandlers(JComponent c)
1376: {
1377: c.addMouseListener(borderListener);
1378: c.addMouseMotionListener(borderListener);
1379: }
1380:
1381:
1388: protected JComponent createNorthPane(JInternalFrame w)
1389: {
1390: titlePane = new BasicInternalFrameTitlePane(w);
1391: return titlePane;
1392: }
1393:
1394:
1401: protected JComponent createWestPane(JInternalFrame w)
1402: {
1403: return null;
1404: }
1405:
1406:
1413: protected JComponent createSouthPane(JInternalFrame w)
1414: {
1415: return null;
1416: }
1417:
1418:
1425: protected JComponent createEastPane(JInternalFrame w)
1426: {
1427: return null;
1428: }
1429:
1430:
1437: protected MouseInputAdapter createBorderListener(JInternalFrame w)
1438: {
1439: return new BorderListener();
1440: }
1441:
1442:
1445: protected void createInternalFrameListener()
1446: {
1447: internalFrameListener = new BasicInternalFrameListener();
1448: }
1449:
1450:
1455: protected final boolean isKeyBindingRegistered()
1456: {
1457:
1458: return false;
1459: }
1460:
1461:
1466: protected final void setKeyBindingRegistered(boolean b)
1467: {
1468:
1469: }
1470:
1471:
1476: public final boolean isKeyBindingActive()
1477: {
1478:
1479: return false;
1480: }
1481:
1482:
1487: protected final void setKeyBindingActive(boolean b)
1488: {
1489:
1490: }
1491:
1492:
1495: protected void setupMenuOpenKey()
1496: {
1497:
1498: }
1499:
1500:
1503: protected void setupMenuCloseKey()
1504: {
1505:
1506: }
1507:
1508:
1513: public JComponent getNorthPane()
1514: {
1515: return northPane;
1516: }
1517:
1518:
1523: public void setNorthPane(JComponent c)
1524: {
1525: replacePane(northPane, c);
1526: northPane = c;
1527: }
1528:
1529:
1534: public JComponent getSouthPane()
1535: {
1536: return southPane;
1537: }
1538:
1539:
1544: public void setSouthPane(JComponent c)
1545: {
1546: replacePane(southPane, c);
1547: southPane = c;
1548: }
1549:
1550:
1555: public void setEastPane(JComponent c)
1556: {
1557: replacePane(eastPane, c);
1558: eastPane = c;
1559: }
1560:
1561:
1566: public JComponent getEastPane()
1567: {
1568: return eastPane;
1569: }
1570:
1571:
1576: public void setWestPane(JComponent c)
1577: {
1578: replacePane(westPane, c);
1579: westPane = c;
1580: }
1581:
1582:
1587: public JComponent getWestPane()
1588: {
1589: return westPane;
1590: }
1591:
1592:
1597: protected DesktopManager getDesktopManager()
1598: {
1599: DesktopManager value = null;
1600: JDesktopPane pane = frame.getDesktopPane();
1601: if (pane != null)
1602: value = frame.getDesktopPane().getDesktopManager();
1603: if (value == null)
1604: value = createDesktopManager();
1605: return value;
1606: }
1607:
1608:
1615: protected DesktopManager createDesktopManager()
1616: {
1617: return new DefaultDesktopManager();
1618: }
1619:
1620:
1625: protected void closeFrame(JInternalFrame f)
1626: {
1627: getDesktopManager().closeFrame(f);
1628: }
1629:
1630:
1635: protected void maximizeFrame(JInternalFrame f)
1636: {
1637: getDesktopManager().maximizeFrame(f);
1638: }
1639:
1640:
1645: protected void minimizeFrame(JInternalFrame f)
1646: {
1647: getDesktopManager().minimizeFrame(f);
1648: }
1649:
1650:
1655: protected void iconifyFrame(JInternalFrame f)
1656: {
1657: getDesktopManager().iconifyFrame(f);
1658: }
1659:
1660:
1665: protected void deiconifyFrame(JInternalFrame f)
1666: {
1667: getDesktopManager().deiconifyFrame(f);
1668: }
1669:
1670:
1675: protected void activateFrame(JInternalFrame f)
1676: {
1677: getDesktopManager().activateFrame(f);
1678: }
1679:
1680:
1685: protected ComponentListener createComponentListener()
1686: {
1687: return new ComponentHandler();
1688: }
1689:
1690:
1695: protected MouseInputListener createGlassPaneDispatcher()
1696: {
1697: return new GlassPaneDispatcher();
1698: }
1699: }