mspaint.java
来自「java实现的简单的画图软件」· Java 代码 · 共 86 行
JAVA
86 行
package com.catking.mainFrm;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import com.catking.buttom.ColorPane;
import com.catking.left.ButtonPane;
import com.catking.middle.MyCanvas;
import com.catking.middle.ResizeSquare;
import com.catking.middle.WhiteSquare;
public class MsPaint {
/**
* @param args
*/
private Display display;
private ButtonPane bp;
private ColorPane cp;
private MyCanvas canvas;
private static final int HEADICON = 0;
public MsPaint(){
display = Display.getDefault();
SourceManager.loadResource();
Shell shell = new Shell(display, SWT.SHELL_TRIM );
shell.setText("未命名-画图");
shell.setImage(SourceManager.imgs[HEADICON]);
buildGUI(shell);
shell.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
shell.pack();
shell.open();
while(! shell.isDisposed()){
if(! display.readAndDispatch())
display.sleep();
}
SourceManager.releaseResource();
}
private void buildGUI(Shell shell){
//Button Pane
bp = new ButtonPane(shell);
cp = new ColorPane(shell);
canvas = new MyCanvas(shell, bp, cp);
shell.setLayout(new FormLayout());
FormData data = new FormData();
data.left = new FormAttachment(0, 5);
data.top = new FormAttachment(0, 5);
bp.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(bp, 5);
data.top = new FormAttachment(0, 5);
data.right = new FormAttachment(100, -5);
canvas.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0, 5);
data.top = new FormAttachment(bp, 5);
data.bottom = new FormAttachment(100, -5);
cp.setLayoutData(data);
}
public static void main(String[] args) {
new MsPaint();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?