package com.laozizhu.search.client.test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* SWT中,Label垂直居中,水平居中的方法.
*
* @author examda
*/
public class LabelVerticleMiddle {
Display display = new Display();
Shell shell = new Shell(display);
Image image = new Image(display, "laozizhu.png");
public LabelVerticleMiddle() {
// 一不小心发现,这个SAHDOW竟然可以垂直居中哦。
CLabel clabel = new CLabel(shell, SWT.SHADOW_NONE);
clabel.setAlignment(SWT.CENTER);
clabel.setImage(image);
clabel.setText("考试大家一起努力哦");
clabel.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
clabel.setBounds(10, 10, 150, 150);
shell.setSize(180, 200);
shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in event queue
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new LabelVerticleMiddle();
}
}
本文来自 280文秘网(https://www.it280.com),转载请保留网址和出处
【Java教程:SWT标签Label垂直居中的方法】相关文章:
2025年外省高中学业水平合格性考试成绩转入江苏认定的通告公布03-29
2012宁夏高考报名方式03-29
Vb中控件的自动排列03-29
写未来的作文300字03-29
Our Mother Is the Same 我们的妈妈是一样的03-29
中国大地保险公司实习报告03-29
小学父爱的作文600字03-29
广西壮族自治区财政厅会计继续教育报名登录入口:https://czt.gxzf.gov.cn/kjgl/03-29
07年4月北师大“中国古代文学史(一)”串讲(5)03-29
汪涵讲述小时候成长经历:鸡毛掸子的故事03-29
