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年外省高中学业水平合格性考试成绩转入江苏认定的通告公布05-15
2012宁夏高考报名方式05-15
Vb中控件的自动排列05-15
写未来的作文300字05-15
Our Mother Is the Same 我们的妈妈是一样的05-15
中国大地保险公司实习报告05-15
小学父爱的作文600字05-15
广西壮族自治区财政厅会计继续教育报名登录入口:https://czt.gxzf.gov.cn/kjgl/05-15
07年4月北师大“中国古代文学史(一)”串讲(5)05-15
汪涵讲述小时候成长经历:鸡毛掸子的故事05-15
