📄 clabel1.java
字号:
package cn.com.chengang.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class CLabel1 {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(200, 100);
// ---------创建窗口中的其他界面组件-------------
shell.setLayout(new FillLayout());
CLabel clabel = new CLabel(shell, SWT.NONE);
clabel.setText("Eclipse从入门到精通");
clabel.setImage(new Image(display, "icons/project.gif"));
Color[] colors = { display.getSystemColor(SWT.COLOR_GREEN), //
display.getSystemColor(SWT.COLOR_RED), //
display.getSystemColor(SWT.COLOR_BLUE) };
int[] percents = { 30, 100 };
clabel.setBackground(colors, percents);
// -----------------END------------------------
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -