Source Code Membuat Animasi Perulangan Pada Java
// Perulangan animasi
do
{
long
time = System.currentTimeMillis();
if(time
- lastDisplay > frameDelay) {
repaint();
try
{
Thread.sleep(frameDelay);
}catch(InterruptedException
ex){
}
++currentFrame;
currentFrame
%= numFrames;
lastDisplay
= time;
}
}
while (true);
}
class
MenuItemHandler implements ActionListener, ItemListener {
public
void actionPerformed(ActionEvent ev){
String
s=ev.getActionCommand();
if(s=="Exit"){
System.exit(0);
}
}
public
void itemStateChanged(ItemEvent e){
}
}
//Kelas
yang digunakan agar tombol close pada frame bisa berfungsi
class
WindowEventHandler extends WindowAdapter {
public
void windowClosing(WindowEvent e){
System.exit(0);
}
}
}
No comments:
Post a Comment