private void updateTabBar(Vector vtThread) { pnlThread.removeAll(); for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) { try { Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex); PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel); String strThreadID = (String) vtThreadInfo.elementAt(0); String strThreadName = (String) vtThreadInfo.elementAt(1); int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2)); mntTemp.setThreadID(strThreadID); mntTemp.setThreadName(strThreadName); mntTemp.setThreadStatus(iThreadStatus); showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3)); mntTemp.addPropertyChangeListener(this); pnlThread.add(strThreadName, mntTemp); mntTemp.updateStatus(); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } Skin.applySkin(this); }
/** TabbedPaneDemo Constructor */ public TabbedPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "TabbedPaneDemo", "toolbar/JTabbedPane.gif"); // create tab position controls JPanel tabControls = new JPanel(); tabControls.add(new JLabel(getString("TabbedPaneDemo.label"))); top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top"))); left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left"))); bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom"))); right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right"))); getDemoPanel().add(tabControls, BorderLayout.NORTH); group = new ButtonGroup(); group.add(top); group.add(bottom); group.add(left); group.add(right); top.setSelected(true); top.addActionListener(this); bottom.addActionListener(this); left.addActionListener(this); right.addActionListener(this); // create tab tabbedpane = new JTabbedPane(); getDemoPanel().add(tabbedpane, BorderLayout.CENTER); String name = getString("TabbedPaneDemo.laine"); JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.ewan"); pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.hania"); pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.bounce"); spin = new HeadSpin(); tabbedpane.add(name, spin); tabbedpane .getModel() .addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) { spin.go(); } } }); }
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; }
public void actionPerformed(ActionEvent e) { if (e.getSource() == top) { tabbedpane.setTabPlacement(JTabbedPane.TOP); } else if (e.getSource() == left) { tabbedpane.setTabPlacement(JTabbedPane.LEFT); } else if (e.getSource() == bottom) { tabbedpane.setTabPlacement(JTabbedPane.BOTTOM); } else if (e.getSource() == right) { tabbedpane.setTabPlacement(JTabbedPane.RIGHT); } }
protected void deleteCurrentPanel() { JComponent tabPane = (JComponent) tabbedPane.getSelectedComponent(); if (tabPane == null) return; WMSPanel wmsPanel = (WMSPanel) tabPane.getClientProperty(Constants.FEATURE_OWNER_PROPERTY); if (tabbedPane.getTabCount() > 2) // actually remove the tab only if there is more than one (plus the "+" tab) tabbedPane.remove(tabPane); else tabbedPane.setTitleAt(1, "New Server"); if (wmsPanel != null) wmsPanel.clearPanel(); }
private synchronized void closeAll() { try { // Close all child window WindowManager.closeAll(); // Remove all child component pnlThread.setVisible(false); pnlUser.setVisible(false); pnlThread.removeAll(); clearAll(txtBoard); tblUser.setData(new Vector()); Thread.sleep(500); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
/* * 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(); } }
PanelThreadMonitor getPanelThreadMonitor(String strThreadID) { Component[] cmp = pnlThread.getComponents(); for (int iMonitorIndex = 0; iMonitorIndex < cmp.length; iMonitorIndex++) { if (cmp[iMonitorIndex] instanceof PanelThreadMonitor) { PanelThreadMonitor mntTemp = ((PanelThreadMonitor) cmp[iMonitorIndex]); if (mntTemp.mstrThreadID.equals(strThreadID)) return mntTemp; } } return null; }
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(); }
/* * Create using the specified focus policy */ public TabFocusHandler(JTabbedPane tabbedPane, int focusPolicy) { if (focusPolicy != RESET_FOCUS && focusPolicy != RETAIN_FOCUS) throw new IllegalArgumentException("Invalid focus policy"); this.tabbedPane = tabbedPane; this.focusPolicy = focusPolicy; // Add listeners to manage a tab change tabbedPane.addChangeListener(this); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener("permanentFocusOwner", this); }
/* * 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); } }
public void loadThread(String threadID, String threadName, String threadStatus) { try { PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel); int iThreadStatus = Integer.parseInt(threadStatus); mntTemp.setThreadID(threadID); mntTemp.setThreadName(threadName); mntTemp.setThreadStatus(iThreadStatus); mntTemp.addPropertyChangeListener(this); pnlThread.add(threadName, mntTemp); mntTemp.updateStatus(); Skin.applySkin(mntTemp); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
/** * The GPropertiesDialog class constructor. * * @param gui the GUI class */ public GPropertiesDialog(GUI gui) { // superclass constructor super(gui, "Properties", false); objects = new ObjectContainer(); // gui this.gui = gui; // set the fixed size setSize(260, 350); setResizable(false); setLayout(null); // set up panels for stuff pane = new JTabbedPane(); // add the tabbed panel tabbedPanePanel = new JPanel(); tabbedPanePanel.add(pane); tabbedPanePanel.setLayout(null); this.getContentPane().add(tabbedPanePanel); tabbedPanePanel.setBounds(0, 0, this.getWidth(), 280); pane.setBounds(0, 0, tabbedPanePanel.getWidth(), tabbedPanePanel.getHeight()); // set up buttons apply = new JButton("Apply"); apply.setBounds(150, 290, 80, 26); this.getContentPane().add(apply); close = new JButton("Close"); close.setBounds(50, 290, 80, 26); this.getContentPane().add(close); addPanel(new GPropertiesPanelCustomObject(gui.getGMap()), "Object"); // add listeners addMouseListener(this); apply.addItemListener(this); apply.addActionListener(this); close.addItemListener(this); close.addActionListener(this); }
protected WMSPanel addNewPanel(final JTabbedPane tabPane) { final WMSPanel wmsPanel = new WMSPanel(null); // the null indicates not to register the panel wmsPanel.initialize(this.controller); wmsPanel.getJPanel().putClientProperty("WMS_PANEL", wmsPanel); tabPane.putClientProperty(wmsPanel.getURLString(), wmsPanel); tabPane.addTab("New Server", wmsPanel.getJPanel()); tabPane.setSelectedIndex(tabPane.getTabCount() - 1); tabPane.setToolTipTextAt(tabbedPane.getSelectedIndex(), "Server WMS Contents"); wmsPanel.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("NewServer")) { String serverLocation = (String) evt.getNewValue(); if (WWUtil.isEmpty(serverLocation)) return; // // // Check to see if it's already open. // for (int i = 0; i < tabbedPane.getTabCount(); i++) // { // JPanel jp = (JPanel) tabbedPane.getTabComponentAt(i); // if (jp != null) // { // WMSPanel wp = (WMSPanel) // jp.getClientProperty("WMS_PANEL"); // if (wp != null && // wp.getURLString().equalsIgnoreCase(serverLocation)) // { // tabbedPane.setSelectedIndex(i); // make it the // visible one // return; // } // } // } try { addNewPanel(tabPane).contactWMSServer(serverLocation); } catch (URISyntaxException e) { e.printStackTrace(); // TODO } } } }); return wmsPanel; }
public void propertyChange(PropertyChangeEvent e) { if (e.getSource() instanceof PanelThreadMonitor) { if (e.getPropertyName().equals("Status")) { PanelThreadMonitor mntTmp = (PanelThreadMonitor) e.getSource(); int iMonitorIndex = pnlThread.indexOfComponent(mntTmp); if (iMonitorIndex >= 0) { if (e.getNewValue().equals("Started")) { if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(COLOR_STARTED)) { pnlThread.setBackgroundAt(iMonitorIndex, COLOR_STARTED); pnlThread.setForegroundAt(iMonitorIndex, COLOR_STARTED_FG); } } else if (e.getNewValue().equals("Stopped")) { if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(SystemColor.controlShadow)) { pnlThread.setBackgroundAt(iMonitorIndex, UIManager.getColor("TabbedPane.background")); pnlThread.setForegroundAt(iMonitorIndex, SystemColor.textText); } } } } } }
public void unloadThread(String strThreadID) { PanelThreadMonitor pnlThrMonitor = getPanelThreadMonitor(strThreadID); pnlThread.remove(pnlThrMonitor); }
public SketchProperties(Editor e, Sketch s) { super(); editor = e; sketch = s; fields = new HashMap<String, JComponent>(); this.setPreferredSize(new Dimension(500, 400)); this.setMinimumSize(new Dimension(500, 400)); this.setMaximumSize(new Dimension(500, 400)); this.setSize(new Dimension(500, 400)); Point eLoc = editor.getLocation(); int x = eLoc.x; int y = eLoc.y; Dimension eSize = editor.getSize(); int w = eSize.width; int h = eSize.height; int cx = x + (w / 2); int cy = y + (h / 2); this.setLocation(new Point(cx - 250, cy - 200)); this.setModal(true); outer = new JPanel(new BorderLayout()); outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(outer); win = new JPanel(); win.setLayout(new BorderLayout()); outer.add(win, BorderLayout.CENTER); buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); saveButton = new JButton("OK"); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); SketchProperties.this.dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SketchProperties.this.dispose(); } }); buttonBar.add(saveButton); buttonBar.add(cancelButton); win.add(buttonBar, BorderLayout.SOUTH); tabs = new JTabbedPane(); overviewPane = new JPanel(); overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS)); overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(overviewPane, "author", "Sketch author:"); addTextArea(overviewPane, "summary", "Summary:"); addTextArea(overviewPane, "license", "Copyright / License:"); tabs.add("Overview", overviewPane); objectsPane = new JPanel(); objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS)); objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(objectsPane, "board", "Board:"); addTextField(objectsPane, "core", "Core:"); addTextField(objectsPane, "compiler", "Compiler:"); addTextField(objectsPane, "port", "Serial port:"); addTextField(objectsPane, "programmer", "Programmer:"); JButton setDef = new JButton("Set to current IDE values"); setDef.setMaximumSize(setDef.getPreferredSize()); setDef.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setObjectValues(); } }); objectsPane.add(Box.createVerticalGlue()); objectsPane.add(setDef); tabs.add("Objects", objectsPane); win.add(tabs, BorderLayout.CENTER); this.setTitle("Sketch Properties"); this.pack(); this.setVisible(true); }
/** Method for removing all current Panels */ public void removeAllPanels() { pane.removeAll(); objects.removeAll(); }
/** * Method for removing a Panel by object reference * * @param object The object to remove */ public void removePanel(GPropertiesPanel object) { pane.remove(object); objects.remove(object); }
/** * Method for removing a Panel by index reference * * @param index The index of the object to remove */ public void removePanel(int index) { pane.remove((GPropertiesPanel) objects.get(index)); objects.remove(index); }
/** * Method for adding a new Panel * * @param object The new Panel */ public void addPanel(GPropertiesPanel object, String title) { pane.add(object, title); objects.add(object); }
public void initialize(final Controller controller) { super.initialize(controller); WWMenu fileMenu = (WWMenu) this.getController().getRegisteredObject(Constants.FILE_MENU); if (fileMenu != null) fileMenu.addMenu(this.getFeatureID()); this.tabbedPane = new JTabbedPane(); this.tabbedPane.setOpaque(false); this.tabbedPane.add(new JPanel()); this.tabbedPane.setTitleAt(0, "+"); // this tab is just a button for adding servers/panels this.tabbedPane.setToolTipTextAt(0, "Connect to WMS Server"); this.tabbedPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { if (tabbedPane.getSelectedIndex() == 0) { addNewPanel(tabbedPane); // Add new panel when '+' is selected } } }); // Add an initial panel to the tabbed pane this.addNewPanel(this.tabbedPane); tabbedPane.setSelectedIndex(1); this.setTaskComponent(this.tabbedPane); this.setLocation(SwingConstants.CENTER, SwingConstants.CENTER); this.getJDialog().setResizable(true); JButton deleteButton = new JButton(ImageLibrary.getIcon("gov/nasa/worldwindow/images/delete-20x20.png")); deleteButton.setToolTipText("Remove Server"); deleteButton.setOpaque(false); deleteButton.setBackground(new Color(0, 0, 0, 0)); deleteButton.setBorderPainted(false); deleteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { deleteCurrentPanel(); } }); deleteButton.setEnabled(true); this.insertLeftDialogComponent(deleteButton); // // JButton cancelButton = new JButton("Cancel"); // cancelButton.setToolTipText("Cancel capabilities retrieval from server"); // cancelButton.setOpaque(false); // cancelButton.addActionListener(new ActionListener() // { // public void actionPerformed(ActionEvent actionEvent) // { // cancelCurrentRetrieval(); // } // }); // this.insertRightDialogComponent(cancelButton); this.setTitle("WMS Servers"); this.dialog.validate(); this.dialog.pack(); }
private void jbInit() throws Exception { //////////////////////////////////////////////////////// // Init LAF //////////////////////////////////////////////////////// ButtonGroup grpLAF = new ButtonGroup(); ActionListener lsnLAF = new ActionListener() { public void actionPerformed(ActionEvent evt) { int iIndex = mvtLAFItem.indexOf(evt.getSource()); if (iIndex >= 0) changeLAF(iIndex); } }; //////////////////////////////////////////////////////// UIManager.LookAndFeelInfo laf = new UIManager.LookAndFeelInfo( "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel"); marrLaf = UIManager.getInstalledLookAndFeels(); int iIndex = 0; while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++; if (iIndex >= marrLaf.length) { UIManager.installLookAndFeel(laf); marrLaf = UIManager.getInstalledLookAndFeels(); } for (iIndex = 0; iIndex < marrLaf.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName()); mnu.addActionListener(lsnLAF); mvtLAFItem.addElement(mnu); mnuUI.add(mnu); grpLAF.add(mnu); } mnuUI.addSeparator(); //////////////////////////////////////////////////////// // Init language //////////////////////////////////////////////////////// ButtonGroup grpLanguage = new ButtonGroup(); ActionListener lsnLanguage = new ActionListener() { public void actionPerformed(ActionEvent e) { int iIndex = mvtLanguageItem.indexOf(e.getSource()); if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex)); } }; //////////////////////////////////////////////////////// String[] str = MonitorDictionary.getSupportedLanguage(); for (iIndex = 0; iIndex < str.length; iIndex++) { JMenuItem mnu = new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage()); mnu.addActionListener(lsnLanguage); mvtLanguage.addElement(str[iIndex]); mvtLanguageItem.addElement(mnu); mnuUI.add(mnu); grpLanguage.add(mnu); } //////////////////////////////////////////////////////// // Add to main menu //////////////////////////////////////////////////////// mnuMain.removeAll(); mnuMain.add(mnuSystem); mnuSystem.add(mnuSystem_Login); mnuSystem.add(mnuSystem_ChangePassword); mnuSystem.addSeparator(); mnuSystem.add(mnuSystem_StopServer); mnuSystem.add(mnuSystem_EnableThreads); mnuMain.add(mnuUI); mnuMain.add(mnuHelp); mnuHelp.add(mnuHelp_About); //////////////////////////////////////////////////////// mnuMain.add(chkVietnamese); mnuMain.add(lblStatus); //////////////////////////////////////////////////////// pnlThread.setTabPlacement(JTabbedPane.LEFT); pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); //////////////////////////////////////////////////////// tblUser.addColumn("", 1, false); tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME); tblUser.addColumn("", 3, false); //////////////////////////////////////////////////////// JPanel pnlMessage = new JPanel(); pnlMessage.setLayout(new GridBagLayout()); pnlMessage.add( new JScrollPane(txtBoard), new GridBagConstraints( 0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( txtMessage, new GridBagConstraints( 0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlMessage.add( btnSend, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); txtBoard.setEditable(false); txtBoard.setAutoscrolls(true); txtBoard.setContentType("text/html"); clearAll(txtBoard); //////////////////////////////////////////////////////// JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4)); pnlUserButton.add(btnKick); pnlUserButton.add(btnRefresh); //////////////////////////////////////////////////////// JPanel pnlManager = new JPanel(new GridBagLayout()); pnlManager.add( new JScrollPane(tblUser), new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); pnlManager.add( pnlUserButton, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 2, 4, 2), 0, 0)); //////////////////////////////////////////////////////// pnlUser.setDividerLocation(320); pnlUser.setLeftComponent(pnlManager); pnlUser.setRightComponent(pnlMessage); pnlUser.setOneTouchExpandable(true); //////////////////////////////////////////////////////// setOrientation(JSplitPane.VERTICAL_SPLIT); setOneTouchExpandable(true); pnlThread.setVisible(false); pnlUser.setVisible(false); setTopComponent(pnlThread); setBottomComponent(pnlUser); //////////////////////////////////////////////////////// pmn.add(mnuSelectAll); pmn.addSeparator(); pmn.add(mnuClearSelected); pmn.add(mnuClearAll); //////////////////////////////////////////////////////// setBorder(BorderFactory.createEmptyBorder()); pnlUser.setBorder(BorderFactory.createEmptyBorder()); pnlManager.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); pnlMessage.setBorder( BorderFactory.createBevelBorder( javax.swing.border.BevelBorder.RAISED, Color.white, UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"), UIManager.getColor("Panel.background"))); //////////////////////////////////////////////////////// Skin.applySkin(mnuMain); Skin.applySkin(tblUser); Skin.applySkin(pmn); Skin.applySkin(this); //////////////////////////////////////////////////////// // Default setting //////////////////////////////////////////////////////// Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0"))); changeDictionary(StringUtil.nvl(prt.get("Language"), "VN")); Skin.LANGUAGE_CHANGE_LISTENER = this; MonitorProcessor.setRootObject(this); updateKeyboardUI(); //////////////////////////////////////////////////////// // Event handler //////////////////////////////////////////////////////// tblUser.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) btnKick.doClick(); } }); //////////////////////////////////////////////////////// btnRefresh.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { try { DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request); if (response != null) { tblUser.setData((Vector) response.getReturn()); if (mstrChannel != null) removeUser(mstrChannel); } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// btnKick.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { int iSelected = tblUser.getSelectedRow(); if (iSelected < 0) return; int iResult = MessageBox.showConfirmDialog( pnlThread, mdic.getString("ConfirmKick"), Global.APP_NAME, MessageBox.YES_NO_OPTION); if (iResult == MessageBox.NO_OPTION) return; try { String strChannel = (String) tblUser.getRow(iSelected).elementAt(0); DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); request.setString("strChannel", strChannel); DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// txtMessage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { btnSend.doClick(); } }); //////////////////////////////////////////////////////// btnSend.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent evt) { if (txtMessage.getText().length() == 0) return; try { DDTP request = new DDTP(); request.setString("strMessage", txtMessage.getText()); channel.sendRequest("ThreadProcessor", "sendMessage", request); txtMessage.setText(""); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } }); //////////////////////////////////////////////////////// mnuClearAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { clearAll(txtBoard); } }); //////////////////////////////////////////////////////// mnuClearSelected.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.setEditable(true); txtBoard.replaceSelection(""); txtBoard.setEditable(false); } }); //////////////////////////////////////////////////////// mnuSelectAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { txtBoard.requestFocus(); txtBoard.selectAll(); } }); //////////////////////////////////////////////////////// txtBoard.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY()); } }); //////////////////////////////////////////////////////// mnuSystem_Login.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { login(); } }); //////////////////////////////////////////////////////// mnuSystem_ChangePassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changePassword(); } }); //////////////////////////////////////////////////////// mnuSystem_StopServer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopServer(); } }); //////////////////////////////////////////////////////// mnuSystem_EnableThreads.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { manageThreads(); } }); //////////////////////////////////////////////////////// mnuHelp_About.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this)); } }); //////////////////////////////////////////////////////// chkVietnamese.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { switchKeyboard(); } }); }
/* * 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); }
public void renameThread(String strThreadID, String strThreadName) { PanelThreadMonitor pnlThrMonitor = getPanelThreadMonitor(strThreadID); pnlThrMonitor.setThreadName(strThreadName); pnlThread.setTitleAt(indexOf(strThreadID), strThreadName); }
public void login() { mbAutoLogIn = false; while (!mbAutoLogIn) { try { // Confirm logout if (isOpen()) { if (MessageBox.showConfirmDialog( this, MonitorDictionary.getString("Confirm.Exit"), Global.APP_NAME, MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) return; // Disconnect from server disconnect(); } // Login DialogLogin dlgLogin = new DialogLogin(this); WindowManager.centeredWindow(dlgLogin); if (dlgLogin.miReturn == JOptionPane.OK_OPTION) { // Update UI SwingUtilities.updateComponentTreeUI(pnlUser); SwingUtilities.updateComponentTreeUI(pnlThread); // Request to connect Socket sck = new Socket(dlgLogin.mstrHost, Integer.parseInt(dlgLogin.mstrPort)); sck.setSoLinger(true, 0); // Start up a channel thread that reads messages from the server channel = new SocketTransmitter(sck) { public void close() { if (msckMain != null) { super.close(); closeAll(); if (mbAutoLogIn) login(); } } }; channel.setUserName(dlgLogin.mstrUserName); channel.setPackage("com.fss.thread."); channel.start(); // Request to Server DDTP request = new DDTP(); request.setRequestID(String.valueOf(System.currentTimeMillis())); request.setString("UserName", dlgLogin.mstrUserName); request.setString("Password", dlgLogin.mstrPassword); // Response from Server DDTP response = channel.sendRequest("ThreadProcessor", "login", request); mstrThreadAppName = response.getString("strThreadAppName"); mstrThreadAppVersion = response.getString("strThreadAppVersion"); mstrAppName = response.getString("strAppName"); mstrAppVersion = response.getString("strAppVersion"); if (response != null) { if (response.getString("PasswordExpired") != null) { DialogChangePassword frm = new DialogChangePassword(this, channel); WindowManager.centeredWindow(frm); if (frm.miReturnValue != JOptionPane.OK_OPTION) throw new AppException("FSS-10003"); } String strLog = StringUtil.nvl(response.getString("strLog"), ""); showResult(txtBoard, strLog); Vector vtThread = response.getVector("vtThread"); updateTabBar(vtThread); mstrChannel = response.getString("strChannel"); if (mstrChannel != null) removeUser(mstrChannel); } btnRefresh.doClick(); pnlThread.setVisible(true); pnlUser.setVisible(true); setResizeWeight(1); setDividerLocation((int) (getSize().getHeight() - 160)); } mbAutoLogIn = true; updateLanguage(); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); // Disconnect from server mstrChannel = null; disconnect(); } } }