📄 basicinternalframeui.java
字号:
} protected JComponent createNorthPane(JInternalFrame w) { titlePane = new BasicInternalFrameTitlePane(w); return titlePane; } protected JComponent createSouthPane(JInternalFrame w) { return null; } protected JComponent createWestPane(JInternalFrame w) { return null; } protected JComponent createEastPane(JInternalFrame w) { return null; } protected MouseInputAdapter createBorderListener(JInternalFrame w) { return new BorderListener(); } protected void createInternalFrameListener(){ internalFrameListener = getHandler(); } protected final boolean isKeyBindingRegistered(){ return keyBindingRegistered; } protected final void setKeyBindingRegistered(boolean b){ keyBindingRegistered = b; } public final boolean isKeyBindingActive(){ return keyBindingActive; } protected final void setKeyBindingActive(boolean b){ keyBindingActive = b; } protected void setupMenuOpenKey(){ // PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't // they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT? // Also, no longer registering on the desktopicon, the previous // action did nothing. InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); SwingUtilities.replaceUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW, map); //ActionMap actionMap = getActionMap(); //SwingUtilities.replaceUIActionMap(frame, actionMap); } protected void setupMenuCloseKey(){ } public JComponent getNorthPane() { return northPane; } public void setNorthPane(JComponent c) { if (northPane != null && northPane instanceof BasicInternalFrameTitlePane) { ((BasicInternalFrameTitlePane)northPane).uninstallListeners(); } replacePane(northPane, c); northPane = c; if (c instanceof BasicInternalFrameTitlePane) { titlePane = (BasicInternalFrameTitlePane)c; } } public JComponent getSouthPane() { return southPane; } public void setSouthPane(JComponent c) { southPane = c; } public JComponent getWestPane() { return westPane; } public void setWestPane(JComponent c) { westPane = c; } public JComponent getEastPane() { return eastPane; } public void setEastPane(JComponent c) { eastPane = c; } public class InternalFramePropertyChangeListener implements PropertyChangeListener { // NOTE: This class exists only for backward compatability. All // its functionality has been moved into Handler. If you need to add // new functionality add it to the Handler, but make sure this // class calls into the Handler. /** * Detects changes in state from the JInternalFrame and handles * actions. */ public void propertyChange(PropertyChangeEvent evt) { getHandler().propertyChange(evt); } } public class InternalFrameLayout implements LayoutManager { // NOTE: This class exists only for backward compatability. All // its functionality has been moved into Handler. If you need to add // new functionality add it to the Handler, but make sure this // class calls into the Handler. public void addLayoutComponent(String name, Component c) { getHandler().addLayoutComponent(name, c); } public void removeLayoutComponent(Component c) { getHandler().removeLayoutComponent(c); } public Dimension preferredLayoutSize(Container c) { return getHandler().preferredLayoutSize(c); } public Dimension minimumLayoutSize(Container c) { return getHandler().minimumLayoutSize(c); } public void layoutContainer(Container c) { getHandler().layoutContainer(c); } }/// DesktopManager methods /** Returns the proper DesktopManager. Calls getDesktopPane() to * find the JDesktop component and returns the desktopManager from * it. If this fails, it will return a default DesktopManager that * should work in arbitrary parents. */ protected DesktopManager getDesktopManager() { if(frame.getDesktopPane() != null && frame.getDesktopPane().getDesktopManager() != null) return frame.getDesktopPane().getDesktopManager(); if(sharedDesktopManager == null) sharedDesktopManager = createDesktopManager(); return sharedDesktopManager; } protected DesktopManager createDesktopManager(){ return new DefaultDesktopManager(); } /** * This method is called when the user wants to close the frame. * The <code>playCloseSound</code> Action is fired. * This action is delegated to the desktopManager. */ protected void closeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation BasicLookAndFeel.playSound(frame,"InternalFrame.closeSound"); // delegate to desktop manager getDesktopManager().closeFrame(f); } /** * This method is called when the user wants to maximize the frame. * The <code>playMaximizeSound</code> Action is fired. * This action is delegated to the desktopManager. */ protected void maximizeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation BasicLookAndFeel.playSound(frame,"InternalFrame.maximizeSound"); // delegate to desktop manager getDesktopManager().maximizeFrame(f); } /** * This method is called when the user wants to minimize the frame. * The <code>playRestoreDownSound</code> Action is fired. * This action is delegated to the desktopManager. */ protected void minimizeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation if ( ! f.isIcon() ) { // This method seems to regularly get called after an // internal frame is iconified. Don't play this sound then. BasicLookAndFeel.playSound(frame,"InternalFrame.restoreDownSound"); } // delegate to desktop manager getDesktopManager().minimizeFrame(f); } /** * This method is called when the user wants to iconify the frame. * The <code>playMinimizeSound</code> Action is fired. * This action is delegated to the desktopManager. */ protected void iconifyFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation BasicLookAndFeel.playSound(frame, "InternalFrame.minimizeSound"); // delegate to desktop manager getDesktopManager().iconifyFrame(f); } /** * This method is called when the user wants to deiconify the frame. * The <code>playRestoreUpSound</code> Action is fired. * This action is delegated to the desktopManager. */ protected void deiconifyFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation if ( ! f.isMaximum() ) { // This method seems to regularly get called after an // internal frame is maximized. Don't play this sound then. BasicLookAndFeel.playSound(frame, "InternalFrame.restoreUpSound"); } // delegate to desktop manager getDesktopManager().deiconifyFrame(f); } /** This method is called when the frame becomes selected. * This action is delegated to the desktopManager. */ protected void activateFrame(JInternalFrame f) { getDesktopManager().activateFrame(f); } /** This method is called when the frame is no longer selected. * This action is delegated to the desktopManager. */ protected void deactivateFrame(JInternalFrame f) { getDesktopManager().deactivateFrame(f); } ///////////////////////////////////////////////////////////////////////// /// Border Listener Class ///////////////////////////////////////////////////////////////////////// /** * Listens for border adjustments. */ protected class BorderListener extends MouseInputAdapter implements SwingConstants { // _x & _y are the mousePressed location in absolute coordinate system int _x, _y; // __x & __y are the mousePressed location in source view's coordinate system int __x, __y; Rectangle startingBounds; int resizeDir; protected final int RESIZE_NONE = 0; private boolean discardRelease = false; int resizeCornerSize = 16; public void mouseClicked(MouseEvent e) { if(e.getClickCount() > 1 && e.getSource() == getNorthPane()) { if(frame.isIconifiable() && frame.isIcon()) { try { frame.setIcon(false); } catch (PropertyVetoException e2) { } } else if(frame.isMaximizable()) { if(!frame.isMaximum()) try { frame.setMaximum(true); } catch (PropertyVetoException e2) { } else try { frame.setMaximum(false); } catch (PropertyVetoException e3) { } } } } // Factor out finishMouseReleased() from mouseReleased(), so that // it can be called by cancelResize() without passing it a null // MouseEvent. void finishMouseReleased() { if (discardRelease) { discardRelease = false; return; } if (resizeDir == RESIZE_NONE) { getDesktopManager().endDraggingFrame(frame); dragging = false; } else { // Remove the WindowFocusListener for handling a // WINDOW_LOST_FOCUS event with a cancelResize(). Window windowAncestor = SwingUtilities.getWindowAncestor(frame); if (windowAncestor != null) { windowAncestor.removeWindowFocusListener( getWindowFocusListener()); } Container c = frame.getTopLevelAncestor(); if (c instanceof RootPaneContainer) { Component glassPane = ((RootPaneContainer)c).getGlassPane(); glassPane.setCursor(Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR)); glassPane.setVisible(false); } getDesktopManager().endResizingFrame(frame); resizing = false; updateFrameCursor(); } _x = 0; _y = 0; __x = 0; __y = 0; startingBounds = null; resizeDir = RESIZE_NONE; // Set discardRelease to true, so that only a mousePressed() // which sets it to false, will allow entry to the above code // for finishing a resize. discardRelease = true; } public void mouseReleased(MouseEvent e) { finishMouseReleased(); } public void mousePressed(MouseEvent e) { Point p = SwingUtilities.convertPoint((Component)e.getSource(), e.getX(), e.getY(), null); __x = e.getX(); __y = e.getY(); _x = p.x; _y = p.y; startingBounds = frame.getBounds(); resizeDir = RESIZE_NONE; discardRelease = false; try { frame.setSelected(true); } catch (PropertyVetoException e1) { } Insets i = frame.getInsets(); Point ep = new Point(__x, __y); if (e.getSource() == getNorthPane()) { Point np = getNorthPane().getLocation(); ep.x += np.x; ep.y += np.y; } if (e.getSource() == getNorthPane()) { if (ep.x > i.left && ep.y > i.top && ep.x < frame.getWidth() - i.right) { getDesktopManager().beginDraggingFrame(frame); dragging = true; return; } } if (!frame.isResizable()) { return; } if (e.getSource() == frame || e.getSource() == getNorthPane()) { if (ep.x <= i.left) { if (ep.y < resizeCornerSize + i.top) { resizeDir = NORTH_WEST; } else if (ep.y > frame.getHeight() - resizeCornerSize - i.bottom) { resizeDir = SOUTH_WEST; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -