Inner Class dan Anonymous Inner Class

Tuesday, March 13, 2012

 
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! :)

ALL TIME HITS

My Latest Vidio

Featured Post

Pembubaran Panitia Pernikahan dan Ulang tahun ke 21

Rasanya miris sendiri lihat blog nggak pernah update padahal bahannya super banyak. Efek mindset saya kekeuh pengen posting semua hal sepu...