How do I convert my following code into an applet for my website?
import java.io.*; import java.net.*; import java.util.regex.*; import java.util.Calendar; import java.util.Random; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class newIrc extends JPanel implements ActionListener { protected static JTextField textField; protected static JTextArea textArea; private final static String newline = "\n"; static Calendar now; static int hour; static int minute; static int second; static String text; static BufferedWriter bw; static String nick; String message2; String[] tok2; public newIrc() { super(new GridBagLayout()); textArea = new JTextArea(10, 20); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); textField = new JTextField(65); textField.addActionListener(this); textField.setBackground(Color.BLACK); textField.setForeground(Color.WHITE); //Add Components to this panel. GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; add(scrollPane, c); c.fill = GridBagConstraints.HORIZONTAL; add(textField, c); } public void actionPerformed(ActionEvent evt) { text = textField.getText(); tok2 = text.split(" "); if (tok2[0].startsWith("/")) { message2 = ""; if (tok2[0].equalsIgnoreCase("/nick")) { message2 = "NICK "+tok2[1]+"\n"; nick = tok2[1]; } if (tok2[0].equalsIgnoreCase("/msg")) { message2 = "PRIVMSG "+tok2[1]+" :"+text.substring(text.indexOf(tok2[2]), text.length())+"\n"; } if (tok2[0].equalsIgnoreCase("/notice")) { message2 = "NOTICE "+tok2[1]+" :"+text.substring(text.indexOf(tok2[2]), text.length())+"\n"; addItem(gettime()+"TO: ("+tok2[1]+") "+text.substring(text.indexOf(tok2[2]), text.length())); } try { bw.write(message2); bw.flush(); } catch (IOException e) {} textField.setText(""); } else { try { bw.write("PRIVMSG #brt93yoda :"+text+"\n"); bw.flush(); } catch (IOException e) {} textField.setText(""); addItem(gettime()+"<"+nick+"> "+text); } } public static void addItem(String text){ textArea.append(text + newline); textArea.setCaretPosition(textArea.getDocument().getLength()); } public static String gettime(){ now = Calendar.getInstance(); hour = now.get(Calendar.HOUR_OF_DAY); if (hour > 12) { hour-=12; } minute = now.get(Calendar.MINUTE); second = now.get(Calendar.SECOND); return "("+hour+":"+minute+":"+second+") "; } private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Bretts Java Client"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add contents to the window. frame.add(new newIrc()); //Display the window. frame.pack(); frame.setResizable(false); frame.setVisible(true); } public static void main(String[] args) { Random generator = new Random(); int r = generator.nextInt(); nick = "USER"+r; createAndShowGUI(); String server = "irc.swiftirc.net"; String address = "thenullbyte.org"; String channel = "#brt93yoda"; String[] tok; int port = 6667; try { //our socket we're connected with Socket irc = new Socket( server, port ); //out output stream bw = new BufferedWriter( new OutputStreamWriter( irc.getOutputStream() ) ); //our input stream BufferedReader br = new BufferedReader( new InputStreamReader( irc.getInputStream() ) ); bw.write( "NICK " + nick + "\n" ); bw.write( "USER " + nick + " " + address + ": Brt93yodas Java Client\n" ); bw.flush(); bw.write( "JOIN " + channel + "\n" ); bw.flush(); addItem("Connecting to Server"); String currLine = null; String message = null; int length; int i; while( ( currLine = br.readLine() ) != null ) { message = currLine; tok = currLine.split(" "); if (tok[1].equalsIgnoreCase("PRIVMSG")) { message = gettime()+"<"+currLine.substring(1, currLine.indexOf("!"))+"> "+tok[3].substring(1)+" "; length = tok.length-1; for (i=4;i<=length;i++) { message+= tok[i]+" "; } } if (tok[1].equalsIgnoreCase("NOTICE") && (currLine.indexOf("!") > 0)) { message = gettime()+"FROM: ("+currLine.substring(1, currLine.indexOf("!"))+") "+tok[3].substring(1)+" "; length = tok.length-1; for (i=4;i<=length;i++) { message+= tok[i]+" "; } } if (tok[1].equals("JOIN")) { message = gettime()+" * "+tok[0].substring(1).replace("!", "(")+") has joined "+tok[2].substring(1); } if (tok[1].equals("PART")) { message = gettime()+" * "+tok[0].substring(1).replace("!", "(")+") has left "+tok[2]; } if (tok[1].equals("INVITE")) {message = "EMPTY"; } if (tok[1].equals("KICK")) { message = gettime()+" * "+tok[3]+" was kicked by "+currLine.substring(1, currLine.indexOf("!"))+" ("+currLine.substring(currLine.indexOf(tok[4])+1, currLine.length())+")"; } if (tok[1].equals("NICK")) { message = currLine.substring(1, currLine.indexOf("!"))+" is now known as "+tok[2].substring(1); } Pattern pingRegex = Pattern.compile( "^PING", Pattern.CASE_INSENSITIVE ); Matcher ping = pingRegex.matcher( currLine ); if( ping.find() ) { bw.write( "PONG " + channel + "\n" ); bw.flush(); message = "EMPTY"; } if (message != "EMPTY") { addItem(message); } } } catch ( UnknownHostException e ) { System.err.println( "No such host" ); } catch ( IOException e ) { System.err.println( "There was an error connecting to the host" ); } } }