• 大小: 57KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: Java
  • 标签: 新手  java  Swing  IO流  

资源简介

非常适合加强java基础的人来练手 完整的画图板项目,模仿win10自带画图板写的 很有学习价值

资源截图

代码片段和文件信息

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
 * 该类用来改变画笔的颜色
 * @author Fan
 *
 */
public class ColorPanel extends JPanel implements MouseListener ActionListener {

public static Paint border_color = new Color(0 0 0);
public static Paint fill_color = null;
private int rgb[][] = {
{ 0 255 128 192 128 255 128 255 0 0 0 0 0 0 128 255 128 255 0 0 0 128 0 128 128
255 128 255 255 255 255 255 }
{ 0 255 128 192 0 0 128 255 128 255 128 255 0 0 0 0 128 255 64 255 128 255 64 128 0
0 64 128 255 255 255 255 }
{ 0 255 128 192 0 0 0 0 0 0 128 255 128 255 128 255 64 128 64 128 255 255 128 255
255 128 0 64 255 255 255 255 } };

private int r g b;
private JPanel leftPanel rightPanel borderPanel fillPanel;
private JPanel[] tsbPanel;
private BufferedImage borderImg = new BufferedImage(16 16 BufferedImage.TYPE_3BYTE_BGR);
private BufferedImage fillImg = new BufferedImage(16 16 BufferedImage.TYPE_3BYTE_BGR);
private JLabel borderLabel = new JLabel(new ImageIcon(borderImg));
private JLabel fillLabel = new JLabel(new ImageIcon(fillImg));
private JLabel special[] = new JLabel[4];
private String[] imgURL = { “./src/img/icon1.gif“ “./src/img/icon2.gif“ “./src/img/icon3.gif“
“./src/img/icon4.gif“ };
private JDialog jianbian;
private JButton left right ok cancel;
private ShowColor jb_panel;
private BufferedImage jb_img = new BufferedImage(100 40 BufferedImage.TYPE_3BYTE_BGR);
private JLabel jb_lb = new JLabel(new ImageIcon(jb_img));
public static Color left_color = Color.BLACK;
public static Color right_color = Color.WHITE;
private boolean isOk;// 是否选择了渐变颜色

public ColorPanel() {
this.setLayout(null);
// 初始化
jianbian = new JDialog();
left = new JButton(“LEFT“);
right = new JButton(“RIGHT“);
ok = new JButton(“OK“);
cancel = new JButton(“cancel“);
leftPanel = new JPanel();
rightPanel = new JPanel();
borderPanel = new JPanel();
fillPanel = new JPanel();
tsbPanel = new JP

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         301  2018-09-03 12:56  画图\.classpath
     文件           6  2018-10-30 15:21  画图\.gitignore
     文件         187  2018-09-26 17:29  画图\.idea\encodings.xml
     文件         234  2018-09-26 17:30  画图\.idea\misc.xml
     文件         252  2018-09-26 17:25  画图\.idea\modules.xml
     文件        9464  2018-09-26 17:32  画图\.idea\workspace.xml
     文件         382  2018-09-03 12:56  画图\.project
     文件         598  2018-09-03 12:56  画图\.settings\org.eclipse.jdt.core.prefs
     文件       10710  2018-11-25 18:19  画图\bin\ColorPanel.class
     文件       15290  2018-11-25 19:29  画图\bin\DrawPanel.class
     文件        8339  2018-11-25 18:19  画图\bin\Painter.class
     文件        5027  2018-11-25 18:19  画图\bin\RightTool.class
     文件         899  2018-11-25 18:19  画图\bin\ShowColor.class
     文件        2014  2018-11-25 18:19  画图\bin\Tab.class
     文件        4494  2018-11-25 18:19  画图\bin\UnderDrawPanel.class
     文件         924  2018-11-13 11:21  画图\bin\img\close.jpg
     文件         836  2004-05-23 20:40  画图\bin\img\icon1.gif
     文件         868  2004-05-23 20:43  画图\bin\img\icon2.gif
     文件         948  2004-05-23 21:54  画图\bin\img\icon3.gif
     文件         835  2004-05-23 22:00  画图\bin\img\icon4.gif
     文件        1558  2004-06-02 01:42  画图\bin\img\paint.gif
     文件         120  2004-05-25 00:52  画图\bin\img\tool1.gif
     文件         130  2004-05-29 18:16  画图\bin\img\tool10.gif
     文件         127  2004-05-30 22:41  画图\bin\img\tool11.gif
     文件         138  2004-05-25 00:51  画图\bin\img\tool2.gif
     文件         138  2004-05-25 00:51  画图\bin\img\tool3.gif
     文件         140  2004-05-25 00:51  画图\bin\img\tool4.gif
     文件         123  2004-05-27 00:53  画图\bin\img\tool5.gif
     文件         893  2004-05-27 00:55  画图\bin\img\tool6.gif
     文件         890  2004-05-27 00:56  画图\bin\img\tool7.gif
     文件         134  2004-05-27 01:07  画图\bin\img\tool8.gif
............此处省略25个文件信息

评论

共有 条评论