/* A basic extension of the java.awt.Frame class */ import java.awt.*; public class Frame4 extends Frame { String s=""; String title4=""; Applet1 app; Thread thread; public Frame4() { // This code is automatically generated by Visual Cafe when you add // components to the visual environment. It instantiates and initializes // the components. To modify the code, only use code syntax that matches // what Visual Cafe can generate, or Visual Cafe may be unable to back // parse your Java file into its visual environment. //{{INIT_CONTROLS setLayout(null); setBackground(new java.awt.Color(208,211,181)); setFont(new Font("Serif", Font.PLAIN, 12)); setSize(481,312); setVisible(false); textArea1.setEditable(false); add(textArea1); textArea1.setForeground(new java.awt.Color(91,0,18)); textArea1.setFont(new Font("Serif", Font.BOLD, 10)); textArea1.setBounds(12,48,340,183); list1.setBackground(new java.awt.Color(208,211,181)); list1.setForeground(new java.awt.Color(91,0,18)); list1.setFont(new Font("Serif", Font.BOLD, 10)); add(list1); list1.setBounds(360,48,108,180); add(textField1); textField1.setForeground(new java.awt.Color(91,0,18)); textField1.setFont(new Font("Serif", Font.BOLD, 10)); textField1.setBounds(12,240,343,24); button1.setLabel("Send"); add(button1); button1.setBackground(new java.awt.Color(208,211,181)); button1.setForeground(new java.awt.Color(91,0,18)); button1.setFont(new Font("Serif", Font.BOLD, 10)); button1.setBounds(384,240,60,24); button2.setLabel("Invite More"); add(button2); button2.setBackground(new java.awt.Color(208,211,181)); button2.setForeground(new java.awt.Color(91,0,18)); button2.setFont(new Font("Serif", Font.BOLD, 10)); button2.setBounds(108,276,59,24); button3.setLabel("Close"); add(button3); button3.setBackground(new java.awt.Color(208,211,181)); button3.setForeground(new java.awt.Color(91,0,18)); button3.setFont(new Font("Serif", Font.BOLD, 10)); button3.setBounds(192,276,60,24); label1.setText("Chat Users"); label1.setAlignment(java.awt.Label.CENTER); add(label1); label1.setForeground(new java.awt.Color(91,0,18)); label1.setFont(new Font("Serif", Font.BOLD, 10)); label1.setBounds(360,12,112,26); setTitle("A Simple Frame"); //}} //{{INIT_MENUS //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); button1.addActionListener(lSymAction); button2.addActionListener(lSymAction); button3.addActionListener(lSymAction); textField1.addActionListener(lSymAction); //}} } public Frame4(String title, Applet1 ap) { this(); setTitle(title); title4=title; app=ap; } /** * Shows or hides the component depending on the boolean flag b. * @param b if true, show the component; otherwise, hide the component. * @see java.awt.Component#isVisible */ public void setVisible(boolean b) { if(b) { setLocation(50, 50); } super.setVisible(b); } public void addNotify() { // Record the size of the window prior to calling parents addNotify. Dimension d = getSize(); super.addNotify(); if (fComponentsAdjusted) return; // Adjust components according to the insets Insets insets = getInsets(); setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height); Component components[] = getComponents(); for (int i = 0; i < components.length; i++) { Point p = components[i].getLocation(); p.translate(insets.left, insets.top); components[i].setLocation(p); } fComponentsAdjusted = true; } // Used for addNotify check. boolean fComponentsAdjusted = false; //{{DECLARE_CONTROLS public static java.awt.TextArea textArea1 = new java.awt.TextArea(); public static java.awt.List list1 = new java.awt.List(4); java.awt.TextField textField1 = new java.awt.TextField(); java.awt.Button button1 = new java.awt.Button(); java.awt.Button button2 = new java.awt.Button(); java.awt.Button button3 = new java.awt.Button(); java.awt.Label label1 = new java.awt.Label(); //}} //{{DECLARE_MENUS //}} class SymWindow extends java.awt.event.WindowAdapter { public void windowClosing(java.awt.event.WindowEvent event) { Object object = event.getSource(); if (object == Frame4.this) Frame4_WindowClosing(event); } } void Frame4_WindowClosing(java.awt.event.WindowEvent event) { app.broadcastMessage("~"+app.randid+"*"+app.user); app.randid=null; app.already=false; this.list1.removeAll(); this.dispose(); } class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == button1) button1_ActionPerformed(event); else if (object == button2) button2_ActionPerformed(event); else if (object == button3) button3_ActionPerformed(event); else if (object == textField1) textField1_ActionPerformed(event); } } void button1_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. System.out.println("before calling broadcastmessage"); if (!textField1.getText().equals("")) { System.out.println("before calling broadcastmessage"); System.out.println("The randid is"+app.randid); String clrtext=textField1.getText(); textField1.setText(""); app.broadcastMessage(app.randid+"%"+clrtext); System.out.println("after calling broadcastmessage"); } } void button2_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. Frame5 more=new Frame5(title4,app); more.setVisible(true); } void button3_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. app.broadcastMessage("~"+app.randid+"*"+app.user); app.randid=null; app.already=false; this.list1.removeAll(); textArea1.setText(""); this.dispose(); } void textField1_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. System.out.println("before calling broadcastmessage"); if (!textField1.getText().equals("")) { System.out.println("before calling broadcastmessage"); System.out.println("The randid is"+app.randid); String clrtext=textField1.getText(); textField1.setText(""); app.broadcastMessage(app.randid+"%"+clrtext); System.out.println("after calling broadcastmessage"); } } }