📄 desktopmediator.java
字号:
* * @param the split pane location * @param the divider location */ public void setSplitPaneDividerLocation(int position, int location) { DockedTabContainer tabContainer = null; switch (position) { case SwingConstants.LEFT: case SwingConstants.RIGHT: baseWindowPane.setSplitPaneDividerLocation(position, location); return; case SwingConstants.WEST: if (westContainer != null) { tabContainer = westContainer; } //tabContainer = initTabContainer(SwingConstants.WEST); break; case SwingConstants.CENTER: if (centerContainer != null) { tabContainer = centerContainer; } //tabContainer = initTabContainer(SwingConstants.CENTER); break; case SwingConstants.EAST: if (eastContainer != null) { tabContainer = eastContainer;//initTabContainer(SwingConstants.EAST); } break; } if (tabContainer != null) { tabContainer.setSplitPaneDividerLocation(location); } } public void splitPaneDividerMoved(int position, int newValue) { switch (position) { case SwingConstants.LEFT: firePropertyChange(LEFT_DIVIDER_LOCATION, -1, newValue); break; case SwingConstants.RIGHT: firePropertyChange(RIGHT_DIVIDER_LOCATION, -1, newValue); break; case SwingConstants.WEST: firePropertyChange(WEST_DIVIDER_LOCATION, -1, newValue); break; case SwingConstants.CENTER: firePropertyChange(CENTER_DIVIDER_LOCATION, -1, newValue); break; case SwingConstants.EAST: firePropertyChange(EAST_DIVIDER_LOCATION, -1, newValue); break; } } /** * Adds the specified drag panel to the frame's * layered pane. * * @param the drag panel */ public void addDragPanel(DragPanel dragPanel) { frame.getLayeredPane().add(dragPanel, JLayeredPane.DRAG_LAYER); } /** * Removes the specified drag panel from the frame's * layered pane. * * @param the drag panel to be removed */ public void removeDragPanel(DragPanel dragPanel) { frame.getLayeredPane().remove(dragPanel); frame.getLayeredPane().repaint(); } /** * Adds the specified component as a docked tab component * in the specified position. * * @param the tab title * @param the component * @param the position */ public void addDockedTab(String title, Component component, int position, boolean selected) { addDockedTab(title, null, component, null, position, selected); } /** * Adds the specified component as a docked tab component * in the specified position. * * @param the tab title * @param the tab icon * @param the component * @param the position */ public void addDockedTab(String title, Icon icon, Component component, int position, boolean selected) { addDockedTab(title, icon, component, null, position, selected); } /** * Adds the specified component as a docked tab component * in the specified position. * * @param the tab title * @param the tab icon * @param the component * @param the position */ public void addDockedTab(TabComponent tabComponent, int position, boolean selected) { addDockedTab(tabComponent.getTitle(), tabComponent.getIcon(), tabComponent.getComponent(), tabComponent.getToolTip(), position, selected); } /** * Adds the specified component as a docked tab component * in the specified position. * * @param the tab title * @param the tab icon * @param the component * @param the tab's tool tip * @param the position */ public void addDockedTab(String title, Icon icon, Component component, String tip, int position, boolean selected) { DockedTabContainer tabContainer = null; switch (position) { case SwingConstants.NORTH_WEST: tabContainer = initTabContainer(SwingConstants.WEST); break; case SwingConstants.SOUTH_WEST: tabContainer = initTabContainer(SwingConstants.WEST); // if there is nothing in the north pane, add there if (!tabContainer.isTabPaneVisible(SwingConstants.NORTH)) { position = SwingConstants.NORTH; } break; case SwingConstants.CENTER: case SwingConstants.SOUTH: tabContainer = initTabContainer(SwingConstants.CENTER); break; case SwingConstants.NORTH_EAST: tabContainer = initTabContainer(SwingConstants.EAST); break; case SwingConstants.SOUTH_EAST: tabContainer = initTabContainer(SwingConstants.EAST); // if there is nothing in the north pane, add there if (!tabContainer.isTabPaneVisible(SwingConstants.NORTH)) { position = SwingConstants.NORTH; } break; } if (tabContainer != null) { tabContainer.addDockedTab(title, icon, component, tip, position); if (selected) { int tabCount = tabContainer.getTabCount(position); tabContainer.setSelectedIndex(position, tabCount - 1); } } } /** * Returns the open tab components in a list at * the specified position. * * @param the tab pane position * @return a list of tab components */ public List<TabComponent> getOpenTabs(int position) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.getOpenTabs(position); } return null; } /** * Sets the tool tip for the specified component to toolTipText * which can be null. An internal exception is raised if there * is no tab for the specified component. * * @param the tab pane position * @param the component where the tool tip should be set * @param the tool tip text to be displayed in the tab */ public void setToolTipTextForComponent(int position, Component component, String toolTipText) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.setToolTipTextForComponent(position, component, toolTipText); } } /** * Selects the next tab from the current selection. */ public void selectNextTab() { if (westContainer != null && westContainer.hasFocusedTabPane()) { TabPane tabPane = westContainer.getTabPaneInFocus(); tabPane.selectNextTab(); } else if (centerContainer != null && centerContainer.hasFocusedTabPane()) { TabPane tabPane = centerContainer.getTabPaneInFocus(); tabPane.selectNextTab(); } else if (eastContainer != null && eastContainer.hasFocusedTabPane()) { TabPane tabPane = eastContainer.getTabPaneInFocus(); tabPane.selectNextTab(); } } /** * Selects the previous tab from the current selection. */ public void selectPreviousTab() { if (westContainer != null && westContainer.hasFocusedTabPane()) { TabPane tabPane = westContainer.getTabPaneInFocus(); tabPane.selectPreviousTab(); } else if (centerContainer != null && centerContainer.hasFocusedTabPane()) { TabPane tabPane = centerContainer.getTabPaneInFocus(); tabPane.selectPreviousTab(); } else if (eastContainer != null && eastContainer.hasFocusedTabPane()) { TabPane tabPane = eastContainer.getTabPaneInFocus(); tabPane.selectPreviousTab(); } } /** * Sets the title of the specified component to title which can be null. * An internal exception is raised if there is no tab for the * specified component. * * @param the tab pane position * @param the component where the title should be set * @param the title to be displayed in the tab */ public void setTabTitleForComponent(int position, Component component, String title) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.setTabTitleForComponent(position, component, title); } } /** * Returns the open tab count at the specified position. * * @param the tab pane position * @return the tab count */ public int getTabCount(int position) { DockedTabContainer container = getContainerAt(position); if (container != null) { return container.getTabCount(position); } return 0; } /** * Returns the selected tab component at the specified position. * * @param the position * @return the component at position */ public TabComponent getSelectedComponent(int position) { DockedTabContainer container = getContainerAt(position); if (container != null) { return container.getComponentAt(position); } return null; } /** * Closed the specfied tab component with name at the specified position. * * @param the name of the tab component * @param the position */ public void closeTabComponent(String name, int position) { DockedTabContainer container = getContainerAt(position); if (container != null) { container.closeTabComponent(name, position); } } /** * Initialises a docked tab container in the specified * position. * * @param the position of this tab container */ private DockedTabContainer initTabContainer(int position) { DockedTabContainer dockedTabContainer = null; switch (position) { case SwingConstants.WEST: if (westContainer == null) { westContainer = new DockedTabContainer(this, position); dockedTabContainer = westContainer; break; } return westContainer; case SwingConstants.CENTER: if (centerContainer == null) { centerContainer = new DockedTabContainer(this, position); dockedTabContainer = centerContainer; break; } return centerContainer; case SwingConstants.EAST: if (eastContainer == null) { eastContainer = new DockedTabContainer(this, position); dockedTabContainer = eastContainer; break; } return eastContainer; } // add to the base pane and attach listeners if (dockedTabContainer != null) { dockedTabContainer.addDockedTabListener(this); baseWindowPane.addComponent(dockedTabContainer, position); } return dockedTabContainer; } /** * Indicates whether the pane at the specified
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -