国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

JAVA小畫板(應(yīng)用程序)

2019-11-18 14:37:02
字體:
供稿:網(wǎng)友
 04年接觸了一段時間的java,期間寫了比較多小程序段,寫得最完整的就是這個JAVA小畫板程序,涉及到鼠標(biāo)事件、畫圖函數(shù)、文件流、文件的打開與保存等內(nèi)容。

//powered by compower
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import java.awt.geom.*;
import java.io.*;

class Point implements Serializable
{
 int x,y;
 Color col;
 int tool;
 int boarder;

 Point(int x, int y, Color col, int tool, int boarder)
 {
  this.x = x;
  this.y = y;
  this.col = col;
  this.tool = tool;
  this.boarder = boarder;
  }
}


class paintboard extends Frame implements ActionListener,MouseMotionListener,MouseListener,ItemListener
{
 int x = -1, y = -1;
 int con = 1;//畫筆大小
 int Econ = 5;//橡皮大小

 int toolFlag = 0;//toolFlag:工具標(biāo)記
      //toolFlag工具對應(yīng)表:
      //(0--畫筆);(1--橡皮);(2--清除);
      //(3--直線);(4--圓);(5--矩形);

 Color c = new Color(0,0,0); //畫筆顏色
 BasicStroke size = new BasicStroke(con,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);//畫筆粗細
 Point cutflag = new Point(-1, -1, c, 6, con);//截斷標(biāo)志

 Vector paintInfo = null;//點信息向量組
 int n = 1;

 FileInputStream picIn = null;
 FileOutputStream picOut = null;
 
 ObjectInputStream VIn = null;
 ObjectOutputStream VOut = null;


// *工具面板--畫筆,直線,圓,矩形,多邊形,橡皮,清除*/
 Panel toolPanel;
 Button eraser, drLine,drCircle,drRect;
 Button clear ,pen;
 Choice ColChoice,SizeChoice,EraserChoice;
 Button colchooser;
 Label 顏色,大小B,大小E;
 //保存功能
 Button openPic,savePic;
 FileDialog openPicture,savePicture;
 

  paintboard(String s)
 { 
  super(s);
  addMouseMotionListener(this);
  addMouseListener(this);

  paintInfo = new Vector();

/*各工具按鈕及選擇項*/
  //顏色選擇
  ColChoice = new Choice();
  ColChoice.add("black");
  ColChoice.add("red");
  ColChoice.add("blue");
  ColChoice.add("green");
  ColChoice.addItemListener(this);
  //畫筆大小選擇
  SizeChoice = new Choice();
  SizeChoice.add("1");
  SizeChoice.add("3");  
  SizeChoice.add("5");
  SizeChoice.add("7");
  SizeChoice.add("9");
  SizeChoice.addItemListener(this);
  //橡皮大小選擇
  EraserChoice = new Choice();
  EraserChoice.add("5");
  EraserChoice.add("9");
  EraserChoice.add("13");
  EraserChoice.add("17");
  EraserChoice.addItemListener(this);
  ////////////////////////////////////////////////////
  toolPanel = new Panel();



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 定南县| 天气| 金湖县| 商南县| 禹城市| 嵊州市| 南安市| 运城市| 韶关市| 汤原县| 弥勒县| 定兴县| 上林县| 彩票| 来安县| 柳江县| 永善县| 工布江达县| 平果县| 宜兰市| 辽中县| 读书| 高邑县| 沾益县| 光泽县| 沁源县| 图木舒克市| 大城县| 兴业县| 克拉玛依市| 庆云县| 金湖县| 新乡市| 陇川县| 法库县| 桦川县| 永靖县| 杂多县| 贵港市| 保定市| 兰考县|