void jListOnlineUsers_mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name); Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2); jTextFieldSendMessages.requestFocus(); } }
private void jbInit() throws Exception { panel1.setLayout(xYLayout1); panel1.setBackground(new Color(251, 236, 175)); jToggleButton5.setText("Done"); jToggleButton5.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jToggleButton5_actionPerformed(e); } }); jLabel1.setToolTipText(""); jList1.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { jList1_mouseClicked(e); } }); HireFire.setText("Hire/Fire"); HireFire.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { HireFire_actionPerformed(e); } }); jButtonAdvertise.setText("Advertise"); jButtonAdvertise.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonAdvertise_actionPerformed(e); } }); jTextFieldWage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jTextFieldWage_actionPerformed(e); } }); jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); jLabel3.setText("Amount"); jLabel5.setText("jLabel5"); jTextFieldWage.setText("100"); panel1.add(jList1, new XYConstraints(9, 10, 206, 250)); panel1.add(jTextPane2, new XYConstraints(9, 262, 467, 109)); panel1.add(jLabel1, new XYConstraints(476, 9, 10, 226)); panel1.add(jLabel2, new XYConstraints(2, 454, 58, 12)); panel1.add(jToggleButton5, new XYConstraints(385, 397, 75, 26)); panel1.add(HireFire, new XYConstraints(9, 429, 134, 26)); panel1.add(jPanel1, new XYConstraints(217, 10, 259, 250)); this.getContentPane().add(panel1, BorderLayout.SOUTH); panel1.add(jButtonAdvertise, new XYConstraints(183, 401, 116, -1)); panel1.add(jTextFieldWage, new XYConstraints(69, 403, 102, 24)); panel1.add(jLabel3, new XYConstraints(19, 400, 46, 29)); panel1.add(jLabel4, new XYConstraints(155, 460, 44, 6)); panel1.add(jLabel5, new XYConstraints(507, 92, 5, 47)); this.setVisible(true); }
void HireFire_actionPerformed(ActionEvent e) { applicant selectedEmp; // employee selected by user from jList if (!appList.isEmpty()) { // Do what you wish the selected applicant selectedEmp = (applicant) jList1.getSelectedValue(); if (selectedEmp.Hired.equals("0")) Moo.send("hire " + selectedEmp.ApplicantID + " " + jTextFieldWage.getText()); else Moo.send("fire"); Moo.send("get_applicants " + jTextFieldWage.getText()); // refreshes list after changes } }
void jTextFieldSendMessages_keyPressed(KeyEvent e) { if (e.getKeyCode() == e.VK_DOWN) { String s = msgHistory.forward(); if (s != null) { jTextFieldSendMessages.setText(s); } } else if (e.getKeyCode() == e.VK_UP) { String s = msgHistory.back(); if (s != null) { jTextFieldSendMessages.setText(s); } } else if (e.getKeyChar() == '\n') { String body = jTextFieldSendMessages.getText(); if (body.length() > 0) { if (body.charAt(body.length() - 1) == '\n') body = body.substring(0, body.length() - 1); String subject = jTextFieldSendSubject.getText(); if (subject.length() > 0) { if (subject.charAt(subject.length() - 1) == '\n') subject = subject.substring(0, subject.length() - 1); } if (session != null && session.isConnected()) { session.postMessage(jTextFieldTargetUser.getText(), subject, body); displaySendMessage(subject, jTextFieldTargetUser.getText(), body, outgoingMsgAttrSet); } msgHistory.add(body); subjectHistory.add(subject); subjectHistory.reset(); msgHistory.reset(); jTextFieldSendMessages.setText(""); jTextFieldSendSubject.setText(""); } } }
public void receiveMsg(Message msg) { // System.out.println(msg.getSubject() + " : " + msg.getBody()); String subject = msg.getSubject(); if (subject != null) { if (subject.equals("online")) { onlineUsers.addElement(new HostItem(msg.getBody())); displayMessage(msg.getBody() + " : Online", onlineClientAttrSet); } else if (subject.equals("offline")) { onlineUsers.removeElement(new HostItem(msg.getBody())); displayMessage(msg.getBody() + " : Offline", offlineClientAttrSet); } else if (subject.equals("eavesdrop enabled")) { Object[] values = jListOnlineUsers.getSelectedValues(); if (values == null) return; for (int i = 0; i < values.length; i++) { ((HostItem) values[i]).eavesDroppingEnabled = true; } jListOnlineUsers.updateUI(); } else if (subject.equals("eavesdrop disabled")) { Object[] values = jListOnlineUsers.getSelectedValues(); if (values == null) return; for (int i = 0; i < values.length; i++) { ((HostItem) values[i]).eavesDroppingEnabled = false; } jListOnlineUsers.updateUI(); } else if (subject.equals("globaleavesdrop enabled")) { displayMessage("Global Eavesdropping Enabled", onlineClientAttrSet); } else if (subject.equals("globaleavesdrop disabled")) { displayMessage("Global Eavesdropping Disabled", offlineClientAttrSet); } else { String to = msg.getTo(); String from = msg.getFrom() == null ? "server" : msg.getFrom(); String body = msg.getBody() != null ? msg.getBody() : ""; if (jTextFieldUser.getText().equals(to)) { // this message is sent to us displayMessage(subject, from, body, incomingMsgAttrSet); } else { // this is an eavesdrop message displayMessage(subject, to, from, body, eavesdropAttrSet); } } } else { subject = ""; String to = msg.getTo(); String from = msg.getFrom() == null ? "server" : msg.getFrom(); String body = msg.getBody() != null ? msg.getBody() : ""; if (jTextFieldUser.getText().equals(to)) { // this message is sent to us displayMessage(subject, from, body, incomingMsgAttrSet); } else { // this is an eavesdrop message displayMessage(subject, to, from, body, eavesdropAttrSet); } } }
void jTextFieldSendSubject_keyPressed(KeyEvent e) { if (e.getKeyCode() == e.VK_DOWN) { String s = subjectHistory.forward(); if (s != null) { jTextFieldSendSubject.setText(s); } } else if (e.getKeyCode() == e.VK_UP) { String s = subjectHistory.back(); if (s != null) { jTextFieldSendSubject.setText(s); } } else if (e.getKeyChar() == '\n') { jTextFieldSendMessages.requestFocus(); } }
private void handleConnect() { if (jToggleButtonConnect.isSelected() || jMenuItemServerConnect.isEnabled()) try { jTextPaneDisplayMessages.setText(""); session = new Session(); try { String userid = jTextFieldUser.getText(); if (jPasswordFieldPwd.getPassword() != null) { String pwd = String.valueOf(jPasswordFieldPwd.getPassword()).trim(); if (!pwd.equals("")) { userid += ":" + pwd; } } if (session.connect(jTextFieldServer.getText(), userid)) { displayMessage("Connected\n", incomingMsgAttrSet); session.addListener(this); jToggleButtonConnect.setText("Disconnect"); jMenuItemServerConnect.setEnabled(false); jMenuItemServerDisconnect.setEnabled(true); } else { jToggleButtonConnect.setSelected(false); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); displayMessage("Connection attempt failed\n", offlineClientAttrSet); } } catch (ConnectionException ex1) { jToggleButtonConnect.setSelected(false); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); displayMessage( "Connection attempt failed: " + ex1.getMessage() + "\n", offlineClientAttrSet); } } catch (Exception ex) { ex.printStackTrace(); } else { disconnect(); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); displayMessage("Disconnected\n", offlineClientAttrSet); } }
/** * Component initialization. * * @throws java.lang.Exception */ private void jbInit() throws Exception { contentPane = (JPanel) getContentPane(); contentPane.setLayout(xYLayoutServer); setSize(new Dimension(365, 327)); setTitle("ProgDan® Codename Avalon: Parser Server v. 0.1"); statusBar.setBorder(BorderFactory.createLoweredBevelBorder()); statusBar.setText("Server stopped!"); jPanelFiles.setBorder(BorderFactory.createEtchedBorder()); jPanelFiles.setToolTipText(""); jPanelFiles.setLayout(xYLayout1); jLabelFiles.setFont(new java.awt.Font("Dialog", Font.BOLD, 11)); jLabelFiles.setText("Files received:"); jLabelConverted.setText("Files converted:"); jProgressBarConvert.setMaximum(0); jProgressBarConvert.setString("0"); jProgressBarConvert.setStringPainted(true); jLabelNoConvert.setText("Files not converted:"); jProgressBarNoConvert.setMaximum(0); jProgressBarNoConvert.setString("0"); jProgressBarNoConvert.setStringPainted(true); jProgressBarNoConvert.addPropertyChangeListener( new FrameServer_jProgressBarNoConvert_propertyChangeAdapter(this)); jButtonStart.setSelected(false); jButtonStart.setText("Start"); jButtonStart.addActionListener(new FrameServer_jButtonStart_actionAdapter(this)); jButtonStop.setEnabled(false); jButtonStop.setText("Stop"); jButtonStop.addActionListener(new FrameServer_jButtonStop_actionAdapter(this)); jButtonExit.setText("Exit"); jButtonExit.addActionListener(new FrameServer_jButtonExit_actionAdapter(this)); jButtonConfig.setText("Config"); jButtonConfig.addActionListener(new FrameServer_jButtonConfig_actionAdapter(this)); jLabelActiveConnections.setText("Active Connections:"); jTextFieldConnections.setEditable(false); jTextFieldConnections.setText("0"); jTextFieldConnections.setHorizontalAlignment(SwingConstants.CENTER); jProgressBarFiles.setMaximum(0); jProgressBarFiles.setString("0"); jProgressBarFiles.setStringPainted(true); jButtonText.setEnabled(false); jButtonText.setText("..."); jButtonText.addActionListener(new FrameServer_jButtonText_actionAdapter(this)); jPanelLogo.setBorder(null); jPanelLogo.setMinimumSize(new Dimension(10, 10)); jPanelLogo.setPreferredSize(new Dimension(10, 10)); jPanelLogo.setLayout(null); jLabelTitle.setFont(new java.awt.Font("Dialog", Font.BOLD, 14)); jLabelTitle.setText("ProgDan® Codename Avalon"); jLabelApplication.setFont(new java.awt.Font("Dialog", Font.BOLD, 24)); jLabelApplication.setForeground(Color.red); jLabelApplication.setText("Parser Server"); jLabelRelease.setFont(new java.awt.Font("Dialog", Font.BOLD, 11)); jLabelRelease.setForeground(Color.red); jLabelRelease.setText("Release 0.1 - Beta"); jLabelCopyright.setText("Copyright 2004-2005 - ProgDan® Software"); jPanelFiles.add(jLabelFiles, new XYConstraints(8, 5, -1, -1)); jPanelFiles.add(jLabelNoConvert, new XYConstraints(8, 50, -1, -1)); jPanelFiles.add(jLabelConverted, new XYConstraints(8, 28, -1, -1)); jPanelFiles.add(jProgressBarFiles, new XYConstraints(108, 3, 160, -1)); jPanelFiles.add(jProgressBarConvert, new XYConstraints(108, 26, 160, -1)); jPanelFiles.add(jProgressBarNoConvert, new XYConstraints(108, 48, 160, -1)); jPanelFiles.add(jButtonText, new XYConstraints(279, 46, -1, -1)); contentPane.add(jTextFieldConnections, new XYConstraints(158, 118, 131, -1)); contentPane.add(jLabelActiveConnections, new XYConstraints(45, 121, -1, -1)); contentPane.add(jButtonExit, new XYConstraints(277, 238, 65, -1)); contentPane.add(jButtonStart, new XYConstraints(11, 238, 65, -1)); contentPane.add(jButtonStop, new XYConstraints(100, 238, 65, -1)); contentPane.add(jButtonConfig, new XYConstraints(188, 238, 65, -1)); contentPane.add(statusBar, new XYConstraints(6, 272, 344, -1)); contentPane.add(jPanelFiles, new XYConstraints(13, 148, 327, 77)); contentPane.add(jPanelLogo, new XYConstraints(13, 15, 112, 96)); contentPane.add(jLabelTitle, new XYConstraints(141, 14, -1, -1)); contentPane.add(jLabelApplication, new XYConstraints(165, 40, -1, -1)); contentPane.add(jLabelRelease, new XYConstraints(250, 66, -1, -1)); contentPane.add(jLabelCopyright, new XYConstraints(137, 95, -1, -1)); }
public void connections(int n) { jTextFieldConnections.setText((new Integer(n)).toString()); }
void jButtonAdvertise_actionPerformed(ActionEvent e) { Moo.send("get_applicants " + jTextFieldWage.getText()); }
private void jbInit() throws Exception { border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder1 = new TitledBorder(border3, "Subject"); border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder2 = new TitledBorder(border4, "Message"); border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder3 = new TitledBorder(border5, "Subject"); border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder4 = new TitledBorder(border6, "Message"); border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder5 = new TitledBorder(border7, "Messages"); border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151)); titledBorder6 = new TitledBorder(border8, "Online Users"); border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178)); titledBorder7 = new TitledBorder(border9, "Send Message"); this.getContentPane().setLayout(borderLayout1); jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT); jSplitPane1.setBorder(border1); jSplitPane1.setLastDividerLocation(250); jSplitPane1.setResizeWeight(1.0); jLabelServer.setRequestFocusEnabled(true); jLabelServer.setText("Server"); jLabelUserId.setText("User Id"); jTextFieldServer.setPreferredSize(new Dimension(75, 20)); jTextFieldServer.setText(""); jTextFieldUser.setPreferredSize(new Dimension(75, 20)); jTextFieldUser.setText(""); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setJMenuBar(jMenuBarMain); this.setTitle("Message Client"); jLabeltargetUser.setText("Target"); jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20)); jTextFieldTargetUser.setText(""); jPanelSendMessages.setBorder(border2); jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767)); jPanelSendMessages.setOpaque(false); jPanelSendMessages.setPreferredSize(new Dimension(96, 107)); jPanelSendMessages.setRequestFocusEnabled(true); jPanelSendMessages.setToolTipText(""); jPanelSendMessages.setLayout(verticalFlowLayout1); jTextFieldSendSubject.setBorder(titledBorder3); jTextFieldSendSubject.setText(""); jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this)); jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT); jScrollPane1.setBorder(titledBorder5); jScrollPane2.setBorder(titledBorder6); jToggleButtonRegister.setText("Register"); jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this)); jButtonMultiConnect.setText("Multi-Connect"); jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this)); jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this)); jToggleButtonConnect.setText("Connect"); jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this)); jTextPaneDisplayMessages.setEditable(false); jTextPaneDisplayMessages.addMouseListener( new Client_jTextPaneDisplayMessages_mouseAdapter(this)); jTextFieldSendMessages.setBorder(titledBorder7); jTextFieldSendMessages.setToolTipText(""); jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this)); jButtonMessageStresser.setText("Msg Stresser"); jButtonMessageStresser.addActionListener( new Client_jToggleButtonMessageStresser_actionAdapter(this)); jMenuItemClearMessages.setText("Clear Messages"); jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this)); jMenuServer.setText("Server"); jMenuItemServerConnect.setText("Connect"); jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this)); jMenuItemServerDisconnect.setText("Disconnect"); jMenuItemServerDisconnect.addActionListener( new Client_jMenuItemServerDisconnect_actionAdapter(this)); jMenuOptions.setText("Options"); jMenuTest.setText("Test"); jMenuItemOptionsRegister.setText("Register"); jMenuItemOptionsRegister.addActionListener( new Client_jMenuItemOptionsRegister_actionAdapter(this)); jMenuItemOptionsDeregister.setText("Deregister"); jMenuItemOptionsDeregister.addActionListener( new Client_jMenuItemOptionsDeregister_actionAdapter(this)); jMenuItemOptionsEavesdrop.setText("Eavesdrop"); jMenuItemOptionsEavesdrop.addActionListener( new Client_jMenuItemOptionsEavesdrop_actionAdapter(this)); jMenuItemOptionsUneavesdrop.setText("Uneavesdrop"); jMenuItemOptionsUneavesdrop.addActionListener( new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this)); jMenuItemTestMulticonnect.setText("Multiconnect"); jMenuItemTestMulticonnect.addActionListener( new Client_jMenuItemTestMulticonnect_actionAdapter(this)); jMenuItemTestMessageStresser.setText("Message Stresser"); jMenuItemTestMessageStresser.addActionListener( new Client_jMenuItemTestMessageStresser_actionAdapter(this)); jMenuItemTestMultidisconnect.setText("Multidisconnect"); jMenuItemTestMultidisconnect.addActionListener( new Client_jMenuItemTestMultidisconnect_actionAdapter(this)); jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop"); jMenuItemOptionsGlobalEavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this)); jMenuItemOptionsGlobalUneavesdrop.setEnabled(false); jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop"); jMenuItemOptionsGlobalUneavesdrop.addActionListener( new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this)); jLabelPwd.setText("Pwd"); jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20)); jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20)); jPasswordFieldPwd.setText(""); jMenuItemScheduleCommand.setText("Schedule Command"); jMenuItemScheduleCommand.addActionListener( new Client_jMenuItemScheduleCommand_actionAdapter(this)); jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands"); jMenuItemEditScheduledCommands.addActionListener( new Client_jMenuItemEditScheduledCommands_actionAdapter(this)); jPanelSendMessages.add(jTextFieldSendSubject, null); jPanelSendMessages.add(jTextFieldSendMessages, null); jSplitPane1.add(jSplitPane2, JSplitPane.TOP); jSplitPane2.add(jScrollPane1, JSplitPane.TOP); jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null); jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM); jScrollPane2.getViewport().add(jListOnlineUsers, null); this.getContentPane().add(jSplitPane1, BorderLayout.CENTER); jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM); this.getContentPane().add(jPanel1, BorderLayout.NORTH); jPanel1.add(jLabelServer, null); jPanel1.add(jTextFieldServer, null); jPanel1.add(jLabelUserId, null); jPanel1.add(jTextFieldUser, null); jPanel1.add(jLabelPwd, null); jPanel1.add(jPasswordFieldPwd, null); jPanel1.add(jLabeltargetUser, null); jPanel1.add(jTextFieldTargetUser, null); jPanel1.add(jToggleButtonConnect, null); jPanel1.add(jToggleButtonRegister, null); jPanel1.add(jButtonMultiConnect, null); jPanel1.add(jButtonMessageStresser, null); jPopupMenuMessageArea.add(jMenuItemClearMessages); jMenuBarMain.add(jMenuServer); jMenuBarMain.add(jMenuOptions); jMenuBarMain.add(jMenuTest); jMenuServer.add(jMenuItemServerConnect); jMenuServer.add(jMenuItemServerDisconnect); jMenuOptions.add(jMenuItemOptionsRegister); jMenuOptions.add(jMenuItemOptionsDeregister); jMenuOptions.add(jMenuItemOptionsEavesdrop); jMenuOptions.add(jMenuItemOptionsUneavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop); jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop); jMenuTest.add(jMenuItemTestMulticonnect); jMenuTest.add(jMenuItemTestMultidisconnect); jMenuTest.add(jMenuItemTestMessageStresser); jMenuTest.add(jMenuItemScheduleCommand); jMenuTest.add(jMenuItemEditScheduledCommands); jSplitPane1.setDividerLocation(200); jSplitPane2.setDividerLocation(600); jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer()); jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jMenuItemTestMulticonnect.setEnabled(true); jMenuItemTestMultidisconnect.setEnabled(false); jMenuItemServerConnect.setEnabled(true); jMenuItemServerDisconnect.setEnabled(false); jMenuItemOptionsRegister.setEnabled(true); jMenuItemOptionsDeregister.setEnabled(false); }