combining into a single class

?

_.-=

Hi!

I know that there is definitely something wrong with this code but I'm
trying to get both the class that creates a frame as well as the class that
implements the WindowListener into one single class so the compiled code
results in a single .class file. Could anyone help me out with this?

import java.awt.*;
import java.awt.event.*;

class SymbiWin {

public static void main(String args[]) {
SymbiWin s1 = new SymbiWin();
}

SymbiWin() {
Frame win1 = new Frame("win1");
Label lab1 = new Label("lab1");
win1.add(lab1);
win1.addWindowListener(this);
win1.pack();
win1.show();
}

public void windowClosing(WindowEvent e) {
System.exit(0);
}

}
 
R

Roedy Green

class SymbiWin extends WindowAdapter {

That is a strange thing to write since SymbWin is not logically a
special kind of WindowAdapter. Normally it would be "implements
WindowListener", or using an anonymous WindowAdapter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top