QQ.JAVA QQ开发
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import yout.FillLayout;
import yout.FormData;
import yout.FormLayout;
import yout.GridData;
import yout.GridLayout;
import yout.RowData;
import yout.RowLayout;
import org.eclipse.swt.widgets.Button;
import bo;
import posite;
import org.eclipse.swt.widgets.Display;
import bel;
import yout;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class QQ {
private static final String jingjing = null;
private StackLayout stackLayout = new StackLayout();
private Composite yourDataComp;
private Composite otherComp;
private Composite PhoneComp;
private List selectList;
private Composite rightComp;
private Image qqImage = new Image(null, "E:\\star.jpg");
private Image starImage = new Image(null, "E:\\star.jpg");
private Image moonImage = new Image(null, "E:\\moon.jpg");
public static void main(String[] args) {
new QQ().open();
}
private void open() {
Display display = Display.getDefault();
final Shell shell = new Shell(SWT.V_SCROLL|SWT.H_SCROLL|SWT.CLOSE|SWT.MAX|SWT.MIN);
shell.setSize(550, 350);
shell.setText("QQ个人情况");
shell.setLayout(new GridLayout());
// 分割窗口
SashForm sashForm = new SashForm(shell, SWT.CLOSE|SWT.MAX|SWT.MIN);
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
selectList = new List(sashForm, SWT.BORDER);
selectList.setItems(new String[] { "个人资料", "联系方式","QQ心情" });
selectList.addSelectionListener(new MySelectionListener());
rightComp = new Composite(sashForm, SWT.NONE);
rightComp.setLayout(stackLayout);
yourDataComp = createYourDataComp(rightComp);
otherComp = createOtherComp(rightComp);
stackLayout.topControl = yourDataComp;
sashForm.setWeights(new int[]{1, 4});
final Composite buttonComp = new Composite(shell, SWT.BORDER);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.END;
buttonComp.setLayoutData(gridData);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 15;
buttonComp.setLayout(rowLayout);
new Button(buttonComp, SWT.NONE).setText(" 确定");
new Button(buttonComp, SWT.NONE).setText(" 取消");
new Button(buttonComp, SWT.NONE).setText(" 应用");
yout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
private Composite createYourDataComp(Composite rightComp) {
Composite comp = new Composite(rightComp, SWT.NONE);
comp.setLayout(new GridLayout(6, false));
new Label(comp, SWT.NONE).setText("用户号码: ");
Text numberText = new Text(comp, SWT.BORDER);
numberText.setText("1277670263");
numberText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3));
Composite photoComp = new Composite(comp, SWT.BORDER);
photoComp.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL|GridData.VERTICAL_ALIGN_FILL,2 ,4));
photoComp.setLayout(new GridLayout(2, false));
createImageComp(photoComp, qqImage);
Button photoButton = new Button(photoComp, SWT.ARROW|SWT.DOWN);
photoButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
Button updateButton = new Button(photoComp, SWT.NONE);
updateButton.setLayoutData(createGridData(
GridData.HORIZONTAL_ALIGN_FILL,2));
updateButton.setText("升级成会员");
new Label(comp,SWT.NONE).setText("用户昵称: ");
Text nickText = new Text(comp, SWT.BORDER);
nickText.setText("臭妞妞猪猪臭鸡蛋大懒猪晶晶猪");
nickText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3));
new Label(comp, SWT.NONE).setText("个性签名: ");
Text descText = new Text(comp, SWT.BORDER);
descText.setText("我困了我饿了口袋没东西了饿死了想吃瓜子");
descText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3));
new Label(comp, SWT.NONE).setText("等级: ");
Composite rankComp = new Composite(comp, SWT.BORDER);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
gridData.heightHint = 50;
rankComp.setLayoutData(gridData);
rankComp.setLayout(new RowLayout());
createImageComp(rankComp, moonImage);
createImageComp(rankComp, moonImage);
createImageComp(rankComp, moonImage);
createImageComp(rankComp, moonImage);
// new Label(comp, SWT.NONE).setText("性别");
// new Combo(comp, SWT.NONE);
new Label(comp, SWT.NONE).setText("性别");
Combo combo = new Combo(comp, 2);
combo.add("男");
combo.add("猪");
new Label(comp, SWT.NONE).setText("姓名:");
Text nameText = new Text(comp, SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
new Label(comp, SWT.NONE).setText("年龄:");
Text oldText = new Text(comp, SWT.BORDER);
oldText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
new Label(comp, SWT.NONE).setText("毕业院校:");
Text schoolText = new Text(comp, SWT.BORDER);
schoolText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,3));
new Label(comp, SWT.NONE).setText("生肖:");
Combo animalCombo = new Combo(comp, SWT.BORDER);
animalCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
new Label(comp, SWT.NONE).setText("工作:");
Combo jobCombo = new Combo(comp, SWT.BORDER);
jobCombo.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL,3));
new Label(PhoneComp,SWT.NONE).setText("联系电话");
Text telephoneText = new Text(PhoneComp,SWT.BORDER);
telephoneText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL,3));
new Label(comp, SWT.NONE).setText("星座:");
Combo starrCombo = new Combo(comp,SWT.NONE);
starrCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
Label introLabel = new Label(comp, SWT.NONE);
introLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
introLabel.setText("个人说明:");
Text introText = new Text(comp, SWT.BORDER|SWT.WRAP);
introText.setLayoutData(createGridData(GridData.HORIZONTAL_ALIGN_FILL |GridData.FILL_VERTICAL,5));
return comp;
}
private Composite createOtherComp(Composite rightComp) {
Composite comp = new Composite(rightComp, SWT.NONE);
comp.setLayout(new FillLayout());
new Label(comp, SWT.NONE).setText("联系方式面板");
return comp;
}
private GridData createGridData(int style, int horizontalSpan) {
GridData girdData = new GridData(style);
girdData.horizontalSpan = horizontalSpan;
return girdData;
}
private GridData createGridData(int style, int horizontalSpan,
int verticalSpan) {
GridData gridData = new GridData(style);
gridData.horizontalSpan = horizontalSpan;
gridData.verticalSpan = verticalSpan;
return gridData;
}
private Composite createImageComp(Composite parent, Image image) { Composite c = new Composite(parent, SWT.NONE);
c.setBackgroundImage(image);
ImageData imageData = image.getImageData();
int width = imageData.width;
int height = imageData.height;
Layout parentLayout = parent.getLayout();
if (parentLayout instanceof GridLayout)
c.setLayoutData(new GridData(width, height));
else if (parentLayout instanceof RowLayout)
c.setLayoutData(new RowData(width, height));
else if (parentLayout instanceof FormLayout)
c.setLayoutData(new FormData(width, height));
return c;
}
private class MySelectionListener extends SelectionAdapter {
public void widgetSelected(SelectionEvent e) {
if (selectList.getSelectionIndex() == 0)
stackLayout.topControl = yourDataComp;
else
stackLayout.topControl = otherComp;
yout();
}
}
}。