使用JAVA创建Paint程序

使用JAVA创建Paint程序

本文介绍了使用JAVA创建Paint程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想法,可以创建一个与Windows中的PAINT程序相同的PAINT程序.我想使用JAVA语言.这是我从互联网上获得的一些编码.

I get an idea to create a PAINT program same with PAINT program in Windows. I want to use JAVA language. This is some of coding that I get from the internet.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Paint extends Applet
implements MouseMotionListener {

int width, height;
Image backbuffer;
Graphics backg;

public void init() {
width = getSize().width;
height = getSize().height;

backbuffer = createImage( width, height );
backg = backbuffer.getGraphics();
backg.setColor( Color.white );
backg.fillRect( 0, 0, width, height );
backg.setColor( Color.red );

backbuffer = createImage( width, height );
backg = backbuffer.getGraphics();
backg.setColor( Color.white );
backg.fillRect( 0, 0, width, height );
backg.setColor( Color.blue );

addMouseMotionListener( this );
}
public void mouseMoved( MouseEvent e ) { }
public void mouseDragged( MouseEvent e ) {
int x = e.getX();
int y = e.getY();
backg.fillOval(x-10,y-10,20,20);
repaint();
e.consume();
}

public void update( Graphics g ) {
g.drawImage( backbuffer, 0, 0, this );
}
public void paint( Graphics g ) {
update( g );
}
}


从这个代码中,我想在该程序中添加一些工具..所以,我希望所有程序员都提供一些建议或想法..如果您有一个指导如何创建它的链接,我将很高兴学习它..

谢谢..


From this code,i want to add some tools in this program..So,i want some advice or idea from all programmer..If u have a link that guide how to create it,im so happy to learn it..

Thank You..

推荐答案


这篇关于使用JAVA创建Paint程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:01