/** * ************************************************ * * <pre> * Summary: Catch any key pressed. * * </pre> * * ************************************************* */ public void keyPressed(KeyEvent e) { // Have an escape do the same as clicking cancel. if (e.getKeyCode() == KeyEvent.VK_ESCAPE) abandonButton.doClick(); // Return else if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (closeButton.isEnabled()) { closeButton.doClick(); } } }
public void actionPerformed(ActionEvent e) { if (cChooser == null) { cChooser = new JColorChooser(); } Color color = cChooser.showDialog( target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor()); target.setIcon(new ColoredIcon(color)); target.doClick(); }
@Override public void mouseReleased(MouseEvent e) { JList list = (JList) e.getComponent(); Point pt = e.getPoint(); int index = list.locationToIndex(pt); if (index >= 0) { JButton button = getButton(list, pt, index); if (Objects.nonNull(button)) { button.doClick(); Rectangle r = list.getCellBounds(index, index); listRepaint(list, r); } } }
@Override public void mouseReleased(MouseEvent e) { // JList list = (JList) e.getComponent(); Point pt = e.getPoint(); int index = list.locationToIndex(pt); if (index >= 0) { JButton button = getButton(list, pt, index); if (Objects.nonNull(button)) { ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer(); renderer.pressedIndex = -1; renderer.button = null; button.doClick(); listRepaint(list, list.getCellBounds(index, index)); } } }
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(); } } }