import javax.swing.*;import t.*;class SetPixel extends JPanel{ Color color; int sX,sY,eX,eY; public SetPixel() { color=Colo
import javax.swing.*;import t.*;class SetPixel extends JPanel{ Color color; int sX,sY,eX,eY; public SetPixel() { color=Color.blue; sX=50; sY=50; eX=100; eY=150; } public void paintComponent(Graphics g) { tColor(color); drawLine(g,sX,sY,eX,eY); } void drawLine(Graphics g,int x1,int y1,int x2,int y2) { g.drawLine(x1,y1,x2,y2); }}public class PixelWindow extends JFrame { public PixelWindow() { super("PixelColor"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(new Rectangle(100,100,300,300)); SetPixel set=new SetPixel(); add(set); } public static void main(String[] args) { PixelWindow setPixel=new PixelWindow(); ow(); }}注意:i:\cdq\PixelWindow.java 使用或覆盖了已过时的 API。注意:要了解详细信息,请使用 - 重新编译。这个是怎么回事??
展开
全部