int indexOf(String strThreadID) { int iMonitorCount = pnlThread.getComponentCount(); for (int iMonitorIndex = 0; iMonitorIndex < iMonitorCount; iMonitorIndex++) { PanelThreadMonitor mntTemp = ((PanelThreadMonitor) pnlThread.getComponentAt(iMonitorIndex)); if (mntTemp.mstrThreadID.equals(strThreadID)) return iMonitorIndex; } return -1; }
/* * Tab has changed. Focus on saved component for the given tab. * When there is no saved component, focus on the first component. */ public void stateChanged(ChangeEvent e) { Component key = tabbedPane.getComponentAt(tabbedPane.getSelectedIndex()); if (key == null) return; Component value = tabFocus.get(key); // First time selecting this tab or focus policy is RESET_FOCUS if (value == null) { key.transferFocus(); tabFocus.put(key, value); } else // Use the saved component for focusing { value.requestFocusInWindow(); } }
public void updateLanguage() { ////////////////////////////////////////////////////////////// mdic = MonitorDictionary.getChildDictionary("ThreadManager"); MonitorDictionary.applyButton(btnKick, "Kick"); MonitorDictionary.applyButton(btnRefresh, "Refresh"); MonitorDictionary.applyButton(btnSend, "Send"); tblUser.setColumnNameEx(mdic.getString("LoginName"), 1); tblUser.setColumnNameEx(mdic.getString("LoginTime"), 2); tblUser.setColumnNameEx(mdic.getString("Host"), 3); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuSelectAll, "jmenu.Edit.SelectAll"); MonitorDictionary.applyButton(mnuClearAll, "jmenu.Edit.ClearAll"); MonitorDictionary.applyButton(mnuClearSelected, "jmenu.Edit.ClearSelected"); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuSystem, "jmenu.System"); MonitorDictionary.applyButton(mnuSystem_ChangePassword, "jmenu.System.ChangePassword"); MonitorDictionary.applyButton(mnuSystem_StopServer, "jmenu.System.Shutdown"); MonitorDictionary.applyButton(mnuSystem_EnableThreads, "jmenu.System.ThreadManager"); MonitorDictionary.applyButton(mnuHelp, "jmenu.Help"); MonitorDictionary.applyButton(mnuHelp_About, "jmenu.Help.About"); ////////////////////////////////////////////////////////////// MonitorDictionary.applyButton(mnuUI, "jmenu.UI"); ////////////////////////////////////////////////////////////// if (isOpen()) { lblStatus.setText( " " + MonitorDictionary.getString("LoggedUser") + ": " + channel.getUserName()); MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Logout"); mnuSystem_ChangePassword.setEnabled(true); mnuSystem_StopServer.setEnabled(true); mnuSystem_EnableThreads.setEnabled(true); } else { lblStatus.setText(""); MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Login"); mnuSystem_ChangePassword.setEnabled(false); mnuSystem_StopServer.setEnabled(false); mnuSystem_EnableThreads.setEnabled(false); } ////////////////////////////////////////////////////////////// for (int iIndex = 0; iIndex < pnlThread.getTabCount(); iIndex++) ((PanelThreadMonitor) pnlThread.getComponentAt(iIndex)).updateLanguage(); }
/* * Track focus changes and update the current focus component * for the current tab */ public void propertyChange(PropertyChangeEvent e) { // No need to track focus change if (exceptions == null && focusPolicy == RESET_FOCUS) return; // Check for exceptions to the focus policy exist Component key = tabbedPane.getComponentAt(tabbedPane.getSelectedIndex()); if (exceptions != null) { if (focusPolicy == RESET_FOCUS && !exceptions.contains(key)) return; if (focusPolicy == RETAIN_FOCUS && exceptions.contains(key)) return; } // Track focus changes for the tab Component value = (Component) e.getNewValue(); if (value != null && SwingUtilities.isDescendingFrom(value, key)) { tabFocus.put(key, value); } }
/* * Specify a tab with an exception to the focus policy rule */ public void addException(int index) { if (exceptions == null) exceptions = new HashSet<Component>(); Component key = tabbedPane.getComponentAt(index); exceptions.add(key); }