由于JFreeChart在swing中不能动态刷新, 所以采用手工的方式来做
[img]http://dl.iteye.com/upload/attachment/521476/3dd50f95-3ef8-3d2a-b6ee-e1669c3ba5d3.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/521476/3dd50f95-3ef8-3d2a-b6ee-e1669c3ba5d3.jpg[/img]
package fiveGame;
import java.awt.BorderLayout;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Panel5 extends JPanel{
public static void main(String[] args) {
JFrame frame = new JFrame();
Panel5 p = new Panel5();
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
frame.setContentPane(p);
frame.setSize(443,552);
frame.setLayout(new BorderLayout());
frame.setVisible(true);
}
@Override
synchronized protected void paintComponent(Graphics g) {
int x = 20;
int y = 450;
int xDistance = 360;
int yDistance = 380;
int letterDistance = 12;
g.drawLine(x, y, x+xDistance, y);
g.drawLine(x, y, x, y-yDistance);
g.drawString(String.valueOf(yDistance), x, y-yDistance);
g.drawString(String.valueOf(0), x, y + letterDistance);
int j = yDistance;
for(int i=33, k=1; i<xDistance; i=i+xDistance/10, k++){
j=j - yDistance/10;
g.drawLine(x+i, y, x+i, y-j);
g.drawString(String.valueOf(j), x+i,y-j);
g.drawString(String.valueOf(k), x+i,y+letterDistance);
}
}
}