• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Compiler Problems with WindowListeners

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiler error, has to do with WindowAdapter and event class. I can't figure it out, please help!
import java.awt.*;
import java.awt.event;
class MyButton extends WindowAdapter {
MyButton() {
Frame f = new Frame("Top Teams in the NFL");
WindowAdapter w = new WindowAdapter();
f.addWindowListener(w);
f.setLayout(new FlowLayout());
f.setSize(500,300);
f.setBackground(Color.darkGray);
Button a = new Button("Raiders");
Button b = new Button("Ravens");
Button c = new Button("Rams");
Button d = new Button("Steelers");
Button e = new Button("Niners");
Button g = new Button("Bears");
f.add(a);
f.add(b);
f.add(c);
f.add(d);
f.add(e);
f.add(g);
f.setVisible(true);
}

public void windowClosing(WindowEvent e) {
window.setVisible(false);
displayMessage("Window closing", e);
}

public static void main(String args[]) {
MyButton mf = new MyButton();
}
}
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Add an asterik after import java.awt.event.*; to start with. Notice the comments in blue. These won't solve all your problems, but I hope it will give you a start.


[This message has been edited by Marilyn deQueiroz (edited November 28, 2001).]
 
Mike Kelly
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marilyn, I'll give it a try. Much appreciated.
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic