/* A basic extension of the java.awt.Dialog class */ import java.awt.*; public class Dialog2 extends Dialog { Frame5 fr; public Dialog2(Frame5 parent) { super(parent); // 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,191)); setFont(new Font("Serif", Font.PLAIN, 12)); setSize(186,122); setVisible(false); label1.setText("Enter the Buddy Id"); add(label1); label1.setBackground(new java.awt.Color(208,211,191)); label1.setForeground(new java.awt.Color(91,0,18)); label1.setFont(new Font("Serif", Font.BOLD, 10)); label1.setBounds(12,12,167,36); add(textField1); textField1.setForeground(new java.awt.Color(91,0,18)); textField1.setFont(new Font("Serif", Font.BOLD, 10)); textField1.setBounds(12,48,169,24); button1.setLabel("Ok"); add(button1); button1.setBackground(new java.awt.Color(208,211,191)); button1.setForeground(new java.awt.Color(91,0,18)); button1.setFont(new Font("Serif", Font.BOLD, 10)); button1.setBounds(36,84,38,24); button2.setLabel("Cancel"); add(button2); button2.setBackground(new java.awt.Color(208,211,191)); button2.setForeground(new java.awt.Color(91,0,18)); button2.setFont(new Font("Serif", Font.BOLD, 10)); button2.setBounds(96,84,48,24); //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); button1.addActionListener(lSymAction); button2.addActionListener(lSymAction); //}} } public Dialog2(Frame5 parent, boolean modal) { this(parent); setModal(modal); fr=parent; } 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; public Dialog2(Frame5 parent, String title, boolean modal) { this(parent, modal); setTitle(title); } /** * 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) { Rectangle bounds = getParent().getBounds(); Rectangle abounds = getBounds(); setLocation(bounds.x + (bounds.width - abounds.width)/ 2, bounds.y + (bounds.height - abounds.height)/2); } super.setVisible(b); } //{{DECLARE_CONTROLS java.awt.Label label1 = new java.awt.Label(); java.awt.TextField textField1 = new java.awt.TextField(); java.awt.Button button1 = new java.awt.Button(); java.awt.Button button2 = new java.awt.Button(); //}} class SymWindow extends java.awt.event.WindowAdapter { public void windowClosing(java.awt.event.WindowEvent event) { Object object = event.getSource(); if (object == Dialog2.this) Dialog2_WindowClosing(event); } } void Dialog2_WindowClosing(java.awt.event.WindowEvent event) { setVisible(false); } 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); } } void button1_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. String s=textField1.getText(); if (!s.equals("")) { int count=Frame1.buddylist.length; for (int i=0;i=0) { String str=(Frame1.buddylist[i]).substring(0,strint); System.out.println("This is substring"+str); if (str.equals(s)) { fr.list1.addItem(s); break; } } } } this.setVisible(false); } void button2_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. this.setVisible(false); } }