Inner Class dan Anonymous Inner Class

8:43 PM

 
Lanjutan dari inner class pada papan...

Contoh Menutup Window
import java.awt.*;
import java.awt.event.*;
class CloseFrame extends Frame{
Label label;
CloseFrame(String title) {
super(title);
label = new Label("Close the frame.");
this.addWindowListener(new CFListener());
}
void launchFrame() {
setSize(300,300);
setVisible(true);
}
class CFListener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(1);
}
}
public static void main(String args[]) {
CloseFrame cf = new CloseFrame("Close Window
Example");
cf.launchFrame();
}
}

Lanjutan dari Anonymouse inner class pada papan...

Contoh Menutup Window
import java.awt.*;
import java.awt.event.*;
class CloseFrame extends Frame{
Label label;
CloseFrame(String title) {
super(title);
label = new Label("Close the frame.");
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
dispose();
System.exit(1);
}
});
}
void launchFrame() {
setSize(300,300);
setVisible(true);
}
public static void main(String args[]) {
CloseFrame cf = new CloseFrame("Close Window Example");
cf.launchFrame();
}
}

source: blog teman saya, rista

ghea safferina adany 

You Might Also Like

0 comments

Drop some hello here! :)

THIS MONTHS HITS

My Latest Vidio

recent posts