67,513
社区成员
发帖
与我相关
我的任务
分享
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ChatServer {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ChatDisplay cds = new ChatDisplay();
cds.setChatLayout("和ssl聊天中...", "你好啊!");
}
}
class ChatDisplay {
private Display cds = new Display();
private Shell shell = new Shell();
public void setChatLayout(String s, String sText) {
shell.setLayout(null);
Text rt = new Text(shell, SWT.MULTI);
Text pt = new Text(shell, SWT.MULTI);
shell.setText(s);
shell.setSize(520, 480);
Color color = new Color(Display.getCurrent(), 255, 0, 255);
shell.setBackground(color);
rt.setText(sText);
rt.setEditable(false);
rt.setSize(520, 300);
pt.setSize(520, 120);
pt.setText("OK");
//t.pack();
shell.open();
while(!shell.isDisposed()) {
if(!cds.readAndDispatch()) {
cds.sleep();
}
}
cds.dispose();
}
}