ich will hier von links nach rechts die zahlen 1-3 auf ein panel schreiben.
ich will das es aussieht als würden sie wandern, doch die spur löscht sich nicht.
ich habe es mit XOR-Mode versucht doch das funktioniert nicht ganz.
wie schaff ich es das sich die "spur" löscht ?
ich will das es aussieht als würden sie wandern, doch die spur löscht sich nicht.
ich habe es mit XOR-Mode versucht doch das funktioniert nicht ganz.
wie schaff ich es das sich die "spur" löscht ?
Code:
import java.awt.Color;
import java.awt.Graphics;
/*
* StringGUI.java
*
*
*/
/**
*
* @author alle
*/
public class StringGUI extends javax.swing.JFrame implements Runnable
{
Graphics g;
Thread t;
int x;
int y;
Color c;
/** Creates new form StringGUI */
public StringGUI()
{
initComponents();
g = pnString.getGraphics();
t = new Thread(this);
x = 0;
y =60;
}
private void OnStart(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OnStart
t.start();
}//GEN-LAST:event_OnStart
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new StringGUI().setVisible(true);
}
});
}
public void run()
{
while(true)
{
g.drawString("1",x,y);
g.drawString("2",x+8,y);
g.drawString("3",x+16,y);
x = x+20;
g.setXORMode(Color.BLACK);
try
{
t.sleep(500);
}
catch (InterruptedException ex)
{
ex.printStackTrace();
}
}
}
}