📄 desktopmediator.java
字号:
* position (left or right) is visible. * * @param SwingConstants.LEFT | SwingConstants.RIGHT * @return true if visible, false otherwise */ public boolean isPaneVisible(int position) { switch (position) { case SwingConstants.WEST: return westContainer != null && (!westContainer.isButtonPanelVisible() || westContainer.isTabPaneVisible(-1)); case SwingConstants.CENTER: return centerContainer != null; case SwingConstants.EAST: return eastContainer != null && (!eastContainer.isButtonPanelVisible() || eastContainer.isTabPaneVisible(-1)); } return false; } /** * Indicates whether the pane at the specified * position (left or right) is visible. * * @param SwingConstants.LEFT | SwingConstants.RIGHT * @return true if visible, false otherwise */ public boolean hasDockedComponentAtPosition(int position) { switch (position) { case SwingConstants.NORTH_WEST: case SwingConstants.SOUTH_WEST: case SwingConstants.WEST: if (isPaneVisible(SwingConstants.WEST)) { return westContainer.isTabPaneVisible(position); } case SwingConstants.SOUTH: if (isPaneVisible(SwingConstants.CENTER)) { return centerContainer.isTabPaneVisible(SwingConstants.SOUTH); } case SwingConstants.NORTH_EAST: case SwingConstants.SOUTH_EAST: case SwingConstants.EAST: if (isPaneVisible(SwingConstants.EAST)) { return eastContainer.isTabPaneVisible(position); } } return false; } /** * Returns the width of the specified pane. * * @return the pane width */ public int getPaneWidth(int position) { switch (position) { case SwingConstants.WEST: if (westContainer != null) { return westContainer.getPaneWidth(); } case SwingConstants.CENTER: if (centerContainer != null) { return centerContainer.getPaneWidth(); } case SwingConstants.EAST: if (eastContainer != null) { return eastContainer.getPaneWidth(); } } return -1; } /** * Resets the split pane component in the specified * position to the preferred sizes of the split pane * children components. * * @param the position of the pane */ public void resetPaneToPreferredSizes(int position, boolean restore) { switch (position) { case SwingConstants.NORTH_WEST: case SwingConstants.SOUTH_WEST: case SwingConstants.CENTER: case SwingConstants.WEST: baseWindowPane.resetPaneToPreferredSizes(SwingConstants.WEST, restore); break; case SwingConstants.NORTH_EAST: case SwingConstants.SOUTH_EAST: case SwingConstants.EAST: baseWindowPane.resetPaneToPreferredSizes(SwingConstants.EAST, restore); break; } } /** * Indicates whether the pane at the specified * position (left or right) is visible. * * @param SwingConstants.LEFT | SwingConstants.RIGHT * @return true if visible, false otherwise */ /* public static boolean isSplitPaneVisible(int position) { boolean visible = frame.isSplitPaneVisible(position); if (visible && position != SwingConstants.CENTER) { switch (position) { case SwingConstants.LEFT: // check we have only the top-left pane if (bottomLeftTabPane == null) { if (topLeftTabPane.isButtonPanelVisible() && topLeftTabPane.hasTabsVisible()) { return true; } } break; case SwingConstants.RIGHT: // check we have only the top-left pane if (bottomRightTabPane == null) { if (topRightTabPane.isButtonPanelVisible() && topRightTabPane.hasTabsVisible()) { return true; } } break; } } return visible; } */ /** * Removes the specified docked tab pane from the * parent split pane and application frame. * * @param the tab pane to remove */ public void removeDockedContainer(DockedTabContainer tabContainer) { int position = tabContainer.getOrientation(); baseWindowPane.removeComponent(position); switch (position) { case SwingConstants.WEST: westContainer = null; break; case SwingConstants.CENTER: centerContainer = null; break; case SwingConstants.EAST: eastContainer = null; break; } /* if (tabPane == topLeftTabPane) { frame.setTopLeftComponent(null); topLeftTabPane = null; // move bottom components to top if (frame.hasBottomLeftComponent()) { frame.setBottomLeftComponent(null); frame.setTopLeftComponent(bottomLeftTabPane); topLeftTabPane = bottomLeftTabPane; bottomLeftTabPane = null; } else { // hide the split pane frame.setLeftSplitPaneVisible(false); } } else if (tabPane == bottomLeftTabPane) { frame.setBottomLeftComponent(null); bottomLeftTabPane = null; } else if (tabPane == bottomCenterTabPane) { frame.setBottomCenterComponent(null); bottomCenterTabPane = null; } else if (tabPane == topRightTabPane) { frame.setTopRightComponent(null); topRightTabPane = null; // move bottom components to top if (frame.hasBottomRightComponent()) { frame.setBottomRightComponent(null); frame.setTopRightComponent(bottomLeftTabPane); topRightTabPane = bottomRightTabPane; bottomRightTabPane = null; } else { // hide the split pane frame.setRightSplitPaneVisible(false); } } else if (tabPane == bottomRightTabPane) { frame.setBottomRightComponent(null); bottomRightTabPane = null; } */ } /** * Restores the tab component with the specified name. * * @param position - the component position in the pane * @param name - the component's name (tab title) */ public void restore(int position, String name) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.restore(name); } } /** * Returns if the tab at the specified position with the * specfied name is currently minimised. * * @param position - the component position in the pane * @param name - the component's name (tab title) */ public boolean isMinimised(int position, String name) { DockedTabContainer container = getContainerAt(position); if (container != null) { return container.isMinimised(name); } return false; } /** * Minimises the tab component with the specified name in * the specified position. * * @param position - the component position in the pane * @param name - the component's name (tab title) */ public void minimiseDockedTab(int position, String name) { DockedTabContainer container = getContainerAt(position); if (container != null) { TabComponent tab = container.getTabComponent(position, name); if (tab != null) { container.minimiseComponent(position, tab.getIndex()); } } } protected DockedTabContainer getContainerAt(int position) { switch (position) { case SwingConstants.NORTH_WEST: case SwingConstants.SOUTH_WEST: case SwingConstants.WEST: return westContainer; case SwingConstants.CENTER: case SwingConstants.SOUTH: return centerContainer; case SwingConstants.NORTH_EAST: case SwingConstants.SOUTH_EAST: case SwingConstants.EAST: return eastContainer; } return null; } /** * Sets the selected panel at the specified index for the tab pane * at the specified position. * * @param position - the tab pane position * @param index - the index to be selected */ public void setSelectedPane(int position, int index) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.setSelectedIndex(position, index); } } /** * Sets the selected panel with the specified title for the tab pane * at the specified position. * * @param position - the tab pane position * @param name - the name/title of the tab to select */ public void setSelectedPane(int position, String name) { DockedTabContainer container = getContainerAt(position); // check we are not already selected // if so - verify focus and return TabComponent tabComponent = getSelectedComponent(position); if (tabComponent != null && name.equals(tabComponent.getTitle())) { /* final TabPane tabPane = container.getTabPaneForPosition(position); if (tabPane != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { tabPane.focusGained(); } }); } */ return; } if (container != null) { container.setSelectedPane(position, name); } } /** * Returns the tab component (or null) at the specified position * with the specified name. * * @param position - the position of the component * @param name - the name of the component (tab title) */ public TabComponent getTabComponent(int position, String name) { DockedTabContainer container = getContainerAt(position); if (container != null) { return container.getTabComponent(position, name); } return null; } /** * Tab drag event listener implementation. * * @param the tab drag event */ public void dockedTabDragged(DockedDragEvent e) { baseWindowPane.dockedTabDragged(e); } /** * Tab drag event listener implementation. * * @param the tab drag event */ public void dockedTabReleased(DockedDragEvent e) { baseWindowPane.dockedTabReleased(e); } public void registerBaseWindowPane(BaseApplicationPane _baseWindowPane) { baseWindowPane = _baseWindowPane; } public JFrame getFrame() { return frame; } public void setFrame(JFrame aFrame) { frame = aFrame; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -