CLabel label = new CLabel(shell, SWT.NONE); // CLabel能实现文本的自动垂直居中
label.setBounds(29, 46, 35, 17);
label.setText("密码:");
text = new Text(shell, SWT.BORDER | SWT.PASSWORD);
text.setBounds(64, 43, 145, 23);
Label label_1 = new Label(shell, SWT.NONE);
label_1.setBounds(224, 46, 54, 17);
label_1.setText("显示密码");
label_1.addMouseListener(new MouseAdapter() {
// 鼠标按下显示明码
public void mouseDown(MouseEvent e) {
text.setEchoChar((char)0);
}
public void mouseUp(MouseEvent e) { // 鼠标松开显示密码
text.setEchoChar('*');
}
});