Home  >  Forum  >  Core Java
Post New Query

Compile Error in my source code while creating my "Button in Java"


joined on
March 15,2013
Asked on September 07,2014
package hostel;
import java.awt.*;
import java.awt.event.ComponentListener;

public class Screen1 {
public static void main(String [] args)
{
Frame frame= new Frame("Hostel Management");
Button button= new Button("Profile");
frame.add(button);
frame.setLayout(new FlowLayout());
frame.setSize(500, 300);
frame.setVisible(true);
frame.addWindowListener(new windowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}

}

joined on
August 11,2014
Replied on September 07,2014

Check frame.addWindowListener() java doc. It says that it accepts
WindowListener() not WindowAdapter.

Your method snippet  could be like

frame.addWindowListener(new WindowListener() {
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
});
}

Define TODO operations.



Write Answer









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us