java Grapics画图形问题

来源:百度知道 编辑:UC知道 时间:2024/07/05 05:28:15
package aaaa;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

public class auto extends JFrame {
public auto() {
add(new autoPanel());

}

public static void main(String[] args) {
auto f1 = new auto();
f1.setTitle("move auto");
f1.setLocationRelativeTo(null);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setSize(800, 100);
f1.setVisible(true);

}

static class autoPanel extends JPanel {
private int x = 0;
private int y = getHeight();
private int xnum;

public autoPanel() {
Timer timer = new Timer(1000, new TimerListener());
timer.start();
}

public void paintCom

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

public class Auto extends JFrame {

public Auto() {
add(new autoPanel());

}

public Auto(String title){
super(title);
}

public static void main(String[] args) {
Auto f1 = new Auto();
f1.setTitle("move auto");
f1.setLocationRelativeTo(null);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setSize(800, 200);
f1.setVisible(true);

}

static class autoPanel extends JPanel {
private int x = 0;
private int y = 0;
private int xnum;

public autoPanel() {
Timer timer = new Timer(1000, new TimerList