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