想在屏幕上显示一个圆点,怎么改
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.Timer;
import java.util.*;public class RLine
{
public static void main(String [] args)
{ RLineFrame bline=new RLineFrame(); bline.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bline.setVisible(true); }}
class RLineFrame extends JFrame
{
public RLineFrame()
{
setTitle("R画点");
setSize(800,600); RLineComponent bLComponent=new RLineComponent(); add(bLComponent);
}
}
class RLineComponent extends JComponent
{
private int x0=0; private int x1=800; private int y0=0; private int y1=600; private int dx; private int x; private int y; private int delay=10; private float k; private float e; public void showOval()
{ k=(float)(y1-y0)/(x1-x0); dx=x1-x0; x=x0; y=y0;
e=-0.5f;
DrawOval ov=new DrawOval(x-4,y-4,8,8); ov.paint(ov.getGraphics());
}
}
class DrawOval extends JComponent
{
private int xb; private int yb; private int rx; private int ry; public DrawOval(int t,int s,int r,int e)
{
xb=t; yb=s; rx=r; ry=e;
} public void paintComponent(Graphics g)
{
super.paintComponent(g); g.setColor(Color.RED); g.fillOval(xb,yb,rx,ry);
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.Timer;
import java.util.*;public class RLine
{
public static void main(String [] args)
{ RLineFrame bline=new RLineFrame(); bline.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bline.setVisible(true); }}
class RLineFrame extends JFrame
{
public RLineFrame()
{
setTitle("R画点");
setSize(800,600); RLineComponent bLComponent=new RLineComponent(); add(bLComponent);
}
}
class RLineComponent extends JComponent
{
private int x0=0; private int x1=800; private int y0=0; private int y1=600; private int dx; private int x; private int y; private int delay=10; private float k; private float e; public void showOval()
{ k=(float)(y1-y0)/(x1-x0); dx=x1-x0; x=x0; y=y0;
e=-0.5f;
DrawOval ov=new DrawOval(x-4,y-4,8,8); ov.paint(ov.getGraphics());
}
}
class DrawOval extends JComponent
{
private int xb; private int yb; private int rx; private int ry; public DrawOval(int t,int s,int r,int e)
{
xb=t; yb=s; rx=r; ry=e;
} public void paintComponent(Graphics g)
{
super.paintComponent(g); g.setColor(Color.RED); g.fillOval(xb,yb,rx,ry);
}
}
1 public void drawOval(int x,int y ,int width,int height) 可以画一个空心圆(包括椭圆和正圆)
x 表示该圆最右顶点的x坐标,y 表示该圆最上顶点的y坐标,width表示该圆的横轴的长度,height表示该圆纵轴的长度。如果width和heigth相等将画出正圆,否则是椭圆。
2 public void fillOval(int x,int y ,int width,int height) 可以画出实心圆。