⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resizesquare.java

📁 java实现的简单的画图软件
💻 JAVA
字号:
package com.catking.middle;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Point;

import com.catking.mainFrm.SourceManager;

public class ResizeSquare extends Canvas{
	private static final int LEFT_RIGHT =  4;
	private static final int RIGHT_BUTTOM =  5;
	private static final int UP_DOWN =  6;

	private Point lastPoint = null;
	private int style;
	private Canvas canvas;
	private Shell shell;


	public ResizeSquare(Shell shell, int style, Canvas c){

		super(shell, SWT.BORDER);
		this.setCursor(SourceManager.curs[style]);
		this.style = style;
		this.canvas = c;
		this.shell = shell;

		this.setBackground(
				Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
		this.addDragDetectListener(new DragDetectListener(){

			public void dragDetected(DragDetectEvent e) {

				lastPoint = new Point(e.x, e.y);
			}

		});
		this.addMouseListener(new MouseAdapter(){

			public void mouseUp(MouseEvent e){

				if(lastPoint != null){

					resize(e.x, e.y);
					lastPoint = null;
				}
			}
		});


	}
	private void resize(int x, int y){

		canvas.setSize(canvas.getSize().x + x, canvas.getSize().y);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -