|
/*
* ProtocolRunner.java
*
* Created on 22 December 2003, 12:57
*/
// Import Java Packages
import java.awt.Point;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.Component;
import java.io.IOException;
import javax.swing.JLabel;
import javax.swing.JDialog;
import javax.swing.UIManager;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JOptionPane;
import java.net.SocketException;
import java.io.File;
import java.util.Date;
import java.util.Calendar;
import javax.swing.JDialog;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.GregorianCalendar;
// Import NET Packages
import org.apache.commons.net.*;
import org.apache.commons.net.io.*;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.nntp.*;
import org.apache.commons.net.pop3.*;
import org.apache.commons.net.smtp.*;
import org.apache.commons.net.tftp.*;
/**
* ProtocolRunner class exercises the various protocols available in the
* Commons Net Package
* @author Vikram Goyal
*/
public class ProtocolRunner extends javax.swing.JFrame {
/** Creates new form ProtocolRunner */
public ProtocolRunner() {
// set the native look and feel
try{
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}catch(Exception e) {}
initComponents();
// size it so that it appears full screen
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
this.setSize(screen.width, screen.height);
this.pack();
this.setExtendedState(Frame.MAXIMIZED_BOTH);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
ftpPanel = new javax.swing.JPanel();
jRadioButton4 = new javax.swing.JRadioButton();
jRadioButton8 = new javax.swing.JRadioButton();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jRadioButton5 = new javax.swing.JRadioButton();
jRadioButton6 = new javax.swing.JRadioButton();
jRadioButton7 = new javax.swing.JRadioButton();
nntpPanel = new javax.swing.JPanel();
jRadioButton10 = new javax.swing.JRadioButton();
jRadioButton15 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton11 = new javax.swing.JRadioButton();
jRadioButton12 = new javax.swing.JRadioButton();
jRadioButton13 = new javax.swing.JRadioButton();
jRadioButton14 = new javax.swing.JRadioButton();
smtpPanel = new javax.swing.JPanel();
jRadioButton17 = new javax.swing.JRadioButton();
jRadioButton18 = new javax.swing.JRadioButton();
jRadioButton16 = new javax.swing.JRadioButton();
pop3Panel = new javax.swing.JPanel();
jRadioButton19 = new javax.swing.JRadioButton();
jRadioButton20 = new javax.swing.JRadioButton();
jRadioButton21 = new javax.swing.JRadioButton();
jRadioButton22 = new javax.swing.JRadioButton();
jRadioButton23 = new javax.swing.JRadioButton();
jRadioButton24 = new javax.swing.JRadioButton();
jRadioButton9 = new javax.swing.JRadioButton();
ftpButtonGroup = new javax.swing.ButtonGroup();
nntpButtonGroup = new javax.swing.ButtonGroup();
smtpButtonGroup = new javax.swing.ButtonGroup();
pop3ButtonGroup = new javax.swing.ButtonGroup();
tftpPanel = new javax.swing.JPanel();
jRadioButton25 = new javax.swing.JRadioButton();
jRadioButton26 = new javax.swing.JRadioButton();
tftpPanelButtonGroup = new javax.swing.ButtonGroup();
loginDialog = new javax.swing.JDialog();
jLabel9 = new javax.swing.JLabel();
jPanel13 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
loginUsername = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
loginPassword = new javax.swing.JPasswordField();
jPanel14 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
singleValueDialog = new javax.swing.JDialog();
jLabel12 = new javax.swing.JLabel();
jPanel15 = new javax.swing.JPanel();
singleValueLabel = new javax.swing.JLabel();
singleValueField = new javax.swing.JTextField();
jPanel16 = new javax.swing.JPanel();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
multipleValueDialog = new javax.swing.JDialog();
jLabel13 = new javax.swing.JLabel();
jPanel17 = new javax.swing.JPanel();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jPanel18 = new javax.swing.JPanel();
jLabel16 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
messageArea = new javax.swing.JTextArea();
jPanel19 = new javax.swing.JPanel();
jLabel14 = new javax.swing.JLabel();
fromField = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
subjectField = new javax.swing.JTextField();
variableLabel = new javax.swing.JLabel();
variableField = new javax.swing.JTextField();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tcpServerResponse = new javax.swing.JTextArea();
jPanel7 = new javax.swing.JPanel();
presetPanel = new javax.swing.JPanel();
defaultPanel = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jPanel9 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
commandBox = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jPanel6 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
tcpSelectionBox = new javax.swing.JComboBox();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
serverNameField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
portNumberField = new javax.swing.JTextField();
tcpConnectButton = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jPanel10 = new javax.swing.JPanel();
jPanel8 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
udpSelectionBox = new javax.swing.JComboBox();
jPanel12 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
udpRemoteServerField = new javax.swing.JTextField();
jPanel11 = new javax.swing.JPanel();
udpCommandPanel = new javax.swing.JPanel();
udpStartButton = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
udpServerResponse = new javax.swing.JTextArea();
ftpPanel.setLayout(new java.awt.GridLayout(3, 3));
jRadioButton4.setText("Login");
ftpButtonGroup.add(jRadioButton4);
jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton4ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton4);
jRadioButton8.setText("Logout");
ftpButtonGroup.add(jRadioButton8);
jRadioButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton8ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton8);
jRadioButton1.setText("Change Working Directory");
ftpButtonGroup.add(jRadioButton1);
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton1);
jRadioButton3.setText("List Files");
ftpButtonGroup.add(jRadioButton3);
jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton3ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton3);
jRadioButton5.setText("Make Directory");
ftpButtonGroup.add(jRadioButton5);
jRadioButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton5ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton5);
jRadioButton6.setText("Upload File");
ftpButtonGroup.add(jRadioButton6);
jRadioButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton6ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton6);
jRadioButton7.setText("Download File");
ftpButtonGroup.add(jRadioButton7);
jRadioButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton7ActionPerformed(evt);
}
});
ftpPanel.add(jRadioButton7);
nntpPanel.setLayout(new java.awt.GridLayout(3, 3));
jRadioButton10.setText("Login");
nntpButtonGroup.add(jRadioButton10);
jRadioButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton10ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton10);
jRadioButton15.setText("Logout");
nntpButtonGroup.add(jRadioButton15);
jRadioButton15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton15ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton15);
jRadioButton2.setText("List All NewsGroups");
nntpButtonGroup.add(jRadioButton2);
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton2);
jRadioButton11.setText("List New NewsGroups");
nntpButtonGroup.add(jRadioButton11);
jRadioButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton11ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton11);
jRadioButton12.setText("List New News");
nntpButtonGroup.add(jRadioButton12);
jRadioButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton12ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton12);
jRadioButton13.setText("Post Article");
nntpButtonGroup.add(jRadioButton13);
jRadioButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton13ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton13);
jRadioButton14.setText("Get Article");
nntpButtonGroup.add(jRadioButton14);
jRadioButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton14ActionPerformed(evt);
}
});
nntpPanel.add(jRadioButton14);
smtpPanel.setLayout(new java.awt.GridLayout(1, 1));
jRadioButton17.setText("Login");
smtpButtonGroup.add(jRadioButton17);
jRadioButton17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton17ActionPerformed(evt);
}
});
smtpPanel.add(jRadioButton17);
jRadioButton18.setText("Logout");
smtpButtonGroup.add(jRadioButton18);
jRadioButton18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton18ActionPerformed(evt);
}
});
smtpPanel.add(jRadioButton18);
jRadioButton16.setText("Send Simple Message");
smtpButtonGroup.add(jRadioButton16);
jRadioButton16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton16ActionPerformed(evt);
}
});
smtpPanel.add(jRadioButton16);
pop3Panel.setLayout(new java.awt.GridLayout(2, 0));
jRadioButton19.setText("Login");
pop3ButtonGroup.add(jRadioButton19);
jRadioButton19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton19ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton19);
jRadioButton20.setText("Logout");
pop3ButtonGroup.add(jRadioButton20);
jRadioButton20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton20ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton20);
jRadioButton21.setText("List All Messages");
pop3ButtonGroup.add(jRadioButton21);
jRadioButton21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton21ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton21);
jRadioButton22.setText("Status");
pop3ButtonGroup.add(jRadioButton22);
jRadioButton22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton22ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton22);
jRadioButton23.setText("Retrieve Message");
pop3ButtonGroup.add(jRadioButton23);
jRadioButton23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton23ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton23);
jRadioButton24.setText("Delete Message");
pop3ButtonGroup.add(jRadioButton24);
jRadioButton24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton24ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton24);
jRadioButton9.setText("Reset");
pop3ButtonGroup.add(jRadioButton9);
jRadioButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton9ActionPerformed(evt);
}
});
pop3Panel.add(jRadioButton9);
tftpPanel.setLayout(new java.awt.GridLayout(1, 0));
jRadioButton25.setText("Send A File");
tftpPanelButtonGroup.add(jRadioButton25);
jRadioButton25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton25ActionPerformed(evt);
}
});
tftpPanel.add(jRadioButton25);
jRadioButton26.setText("Receive A File");
tftpPanelButtonGroup.add(jRadioButton26);
jRadioButton26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton26ActionPerformed(evt);
}
});
tftpPanel.add(jRadioButton26);
loginDialog.getContentPane().setLayout(new java.awt.BorderLayout(0, 5));
loginDialog.setTitle("Input Required");
loginDialog.setModal(true);
loginDialog.setResizable(false);
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel9.setText("Please Enter Login Details");
loginDialog.getContentPane().add(jLabel9, java.awt.BorderLayout.NORTH);
jPanel13.setLayout(new java.awt.GridLayout(2, 2, 5, 3));
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel10.setText("Username:");
jPanel13.add(jLabel10);
loginUsername.setColumns(15);
jPanel13.add(loginUsername);
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel11.setText("Password:");
jPanel13.add(jLabel11);
loginPassword.setColumns(15);
jPanel13.add(loginPassword);
loginDialog.getContentPane().add(jPanel13, java.awt.BorderLayout.CENTER);
jPanel14.setLayout(new java.awt.GridLayout(1, 0));
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel14.add(jButton1);
jButton2.setText("Cancel");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel14.add(jButton2);
loginDialog.getContentPane().add(jPanel14, java.awt.BorderLayout.SOUTH);
singleValueDialog.setTitle("Input Required");
singleValueDialog.setModal(true);
singleValueDialog.setResizable(false);
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel12.setText("Please enter a value");
singleValueDialog.getContentPane().add(jLabel12, java.awt.BorderLayout.NORTH);
jPanel15.setLayout(new java.awt.GridLayout(1, 0, 3, 0));
singleValueLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jPanel15.add(singleValueLabel);
singleValueField.setColumns(15);
jPanel15.add(singleValueField);
singleValueDialog.getContentPane().add(jPanel15, java.awt.BorderLayout.CENTER);
jPanel16.setLayout(new java.awt.GridLayout(1, 0, 5, 0));
jButton3.setText("OK");
|