Problema de programación de gráficos 2D en Java ¡Ayuda urgente!
importar java.awt.Graphics;
importar javax.swing.public clase MainFrame extiende JPanel implementa Runnable {
boolean isLight = false;
public MainFrame() {
new Thread(this start();
}
public void paintComponent. (Gráficos g) {
g.drawLine(70, 250, 130, 250);
} else {
g.setColor(Color.amarillo) ;
g.fillArc(70, 200, 60, 100, 0, 180);
}
}> }
public void run() {
while (true) {
if (isLight) {
prueba {
Thread.sleep( 10000);
} catch (InterruptedException e) {
// TODO Bloque catch generado automáticamente
e.printStackTrace();
}
isLight = false;
} más {<
prueba {
Thread.sleep(1000); p>
} catch (InterruptedException e) {
// TODO Bloque de captura generado automáticamente
e.printStackTrace().printStackTrace();
}
isLight = true;
}
repintar();
}
} p>
public static void main(String[] args) {
JFrame jf = new JFrame();
jf.getContentPane().add( nuevo MainFrame());
jf.setVisible(true);
jf.setSize(200, 500);
}
}