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

📄 errorframe.java

📁 用swt作的一个类似飞鸽一样的局域网通信工具
💻 JAVA
字号:
package view.error;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;

import ThemeFrame.SAPWindowFrame;
import org.eclipse.swt.graphics.Rectangle;

public class ErrorFrame extends Composite {
	final static public String ERROR = "ERROR";  
	final static public String ALERM = "ALERM"; 
	private Image picture = null;
	private CLabel cLabel = null;
	private Button button = null;
	private Text text = null;
	public ErrorFrame(Composite parent, int style) {
		super(parent, style);
		initialize();
	}
	public void setMessage(String msg){
		text.setText(msg);
	}
	public void setErrorPicture(String picture){
		if (picture.equals(ALERM)){
			if (cLabel!=null){
				this.picture = new Image(Display.getCurrent(), getClass().getResourceAsStream("/view/picture/Alerm.png"));
				cLabel.setImage(this.picture);
			}
		}else if (picture.equals(ERROR)){
			if (cLabel!=null){
				this.picture = new Image(Display.getCurrent(), getClass().getResourceAsStream("/view/picture/Error.png"));
				cLabel.setImage(this.picture);
			}
		}
	}
	private void initialize() {
		this.setBounds(new Rectangle(0, 0, 291, 73));
		cLabel = new CLabel(this, SWT.NONE);
		cLabel.setText("");
		cLabel.setBounds(new Rectangle(3, 6, 53, 62));
		cLabel.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		button = new Button(this, SWT.NONE);
		button.setBounds(new Rectangle(223, 44, 62, 22));
		button.setText("关闭(&C)");
		text = new Text(this, SWT.MULTI);
		text.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		text.setBounds(new Rectangle(58, 7, 224, 34));
		text.setEditable(false);
		button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
			public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
				if (picture!=null) picture.dispose();
				if (cLabel!=null) cLabel.dispose();
				if (button!=null) button.dispose();
				if (text!=null) text.dispose();
				getShell().close();
				ErrorFrame.this.dispose();
			}
		});
	}
}  

⌨️ 快捷键说明

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