Dear All,
I am writing the following code but I am facing some problem.

    public void actionPerformed(ActionEvent ae)
    {
    if (ae.getSource()==connect)
        {
      JOptionPane.showMessageDialog(null, "Connection Estabilished");       
       }
      else if (ae.getSource()==disconnect)
        {
        JOptionPane.showMessageDialog(null, "Connection Disconnect");
          } 
    }

When I Write this code, compiler compile this code but does not show messagebox when i clicked on buttons...........
Anyone please help me....
I am waiting for your help
Thanks

Do you have the source you can show us where you are assigning the buttons?
Make sure you are adding the action listener from both buttons. Also assuming those two objects are buttons.

connect.addActionListener(this);
disconnect.addActionListener(this);

Add an else at the end of the if/else if chain and have it print out the contents of the event object. That handles the case where none of the above were true.

You should always add an ending else to catch unexpected cases & problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.