kenikavanbis
Terugkerende gebruiker
- Lid geworden
- 22 mei 2007
- Berichten
- 2.196
Nu heb ik een progje gemaakt en werkt (let op img vanuit package benadert) maar hij blijft na kill werken hoe zou ik die kunnen vernietigen.
aanroep
Code:
package be.djdb.cv;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;
import javax.swing.Timer;
import be.djdb.Statics;
public class Toren extends JInternalFrame implements ActionListener {
Image pictures[] ;
private Timer timer;
private int i =0;
private JTextField text;
private int max ;
private int toolheight;
private int minheight =670;
private int thisheight=5;
private int thiswidth=5;
private int minwidth=550;
Toren(){
setBounds(1,1, 785, 600);
timer = new Timer(400, this);
timer.start();
text= new JTextField("één"+i);
max = 4;
setLayout(new BorderLayout());
log(Level.WARNING,"=>initalise");
setTitle("Mytower");
setMaximizable(false);
setIconifiable(true);
setClosable(true);
setResizable(false);
pictures =new Image[max];
pictures[0]=new ImageIcon(Toren.class.getResource("/img/toren/Toren1.gif")).getImage();
pictures[1]=new ImageIcon(Toren.class.getResource("/img/toren/Toren2.gif")).getImage();
pictures[2]=new ImageIcon(Toren.class.getResource("/img/toren/Toren3.gif")).getImage();
pictures[3]=new ImageIcon(Toren.class.getResource("/img/toren/Toren4.gif")).getImage();
}
private static void log(Level level, String msg ){
String tag ="<>>>>*"+Statics.LIBNAME+"-"+Statics.COPYRIGHTBY+"*<<<<>";
Logger.getLogger(Toren.class.getName()).log(level, tag + msg);
}
@Override
public void actionPerformed(ActionEvent e) {
next();
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
text.setText("twee"+i);
//this.add(text);
super.paint(g);
Draw(g2d);
}
private void next() {
i++;
if(max==i){
i=0;
}
System.out.println(i);
repaint();
}
@Override
protected void finalize() throws Throwable {
timer.stop();
timer=null;
super.finalize();
}
public void Draw(Graphics2D g2d) {
g2d.drawImage(pictures[i], 4, 30 + 1, this);
}
public void setBounds(int top,int left,int with,int height){
thisheight= (height>minheight+toolheight)?height:minheight+toolheight;
thiswidth= (with>minwidth)?with:minwidth;
super.setBounds(top,left,thiswidth,thisheight);
}
public Dimension resizeto(Dimension d){
Rectangle cord = getBounds();
cord.width = d.width;
cord.height = d.height;
this.setBounds(cord);
return new Dimension(thiswidth, thisheight);
}
}
Code:
run = new ActionListener(){
public void actionPerformed(ActionEvent evt) {
toren();
}
};
...
__
...
private void toren(){
super.add(new Toren());
}