Case study of compiling QQ profile interface with SWT

Source: Internet
Author: User
Tags email account

/*
* @ (#) Qqpersonalsetwindows. Java 1.0 09/03/26
*
* All Rights Reserved.
*/
Package cn.edu. Tsinghua. cs. Keg. Andy. SWT;

Import org. Eclipse. SWT. SWT;
Import org. Eclipse. SWT. Custom. sashform;
Import org. Eclipse. SWT. Custom. stacklayout;
Import org. Eclipse. SWT. Events. mouseadapter;
Import org. Eclipse. SWT. Events. mouseevent;
Import org. Eclipse. SWT. layout. griddata;
Import org. Eclipse. SWT. layout. gridlayout;
Import org. Eclipse. SWT. layout. rowlayout;
Import org. Eclipse. SWT. Widgets. Button;
Import org. Eclipse. SWT. Widgets. Combo;
Import org. Eclipse. SWT. Widgets. composite;
Import org. Eclipse. SWT. Widgets. display;
Import org. Eclipse. SWT. Widgets. label;
Import org. Eclipse. SWT. Widgets. List;
Import org. Eclipse. SWT. Widgets. shell;
Import org. Eclipse. SWT. Widgets. text;

/**
* QQ Personal Data Input Device
* @ Author Andy Wang
* @ Version 1.0 09/03/26
* @ Since jdk5.0
*/
Public class qqpersonalsetwindows {
 
Private final string [] items = new string [] {"Profile", "Contact Info "};
Private final string [] sexs = new string [] {"male", "female "};
Private final string [] authoritys = new string [] {"completely public", "only visible to friends", "completely confidential "};
Private final string [] stars = new string [] {"," Aquarius "," Pisces "," Aries "," Taurus "," Gemini "," cancer ", "Leo", "Virgo", "Libra", "scorpio", "Sagittarius", "Capricorn "};
Private final string [] shengxiaos = new string [] {"", "rat", "Ox", "Tiger", "rabbit", "dragon", "snake ", "horse", "goat", "monkey", "chicken", "dog", "Swine "};
Private final string [] bloods = new string [] {"", "A", "B", "O", "AB", "other "};
Private final string [] months = new string [] {"," August ", "August", "August "};
Private final string [] days = new string [] {"", "1", "2", "3", "4", "5 ", "6", "7 ",
"8", "9", "10", "11", "12", "13", "14", "15 ", "16", "17", "18", "19 ",
"20", "21", "22", "23", "24", "25", "26", "27 ", "28", "29", "30", "31 "};
 
Private string signtexts = "You have no personalized signature. Sign it now !! ";
 
Private stacklayout;
Private composite rightpersonalcom;
Private composite rightcontactcom;
Private composite rightcom;

Private qqpersonalsetwindows (){}
 
/**
*
*/
Public void open (){

Display display = New Display ();

Final shell = new shell (display, SWT. Border | SWT. Close | SWT. min );
Shell. setsize (500,420 );
Shell. settext ("QQ personal Settings ");
Shell. settooltiptext ("My Documents-personal settings, please fill in the content! ");
Gridlayout = new gridlayout ();
Shell. setlayout (gridlayout );
{
// The split window is left and right
Sashform = new sashform (shell, SWT. None );

Griddata = new griddata (griddata. fill_both );
Sashform. setlayoutdata (griddata );
{
// Split the list box on the left
List selectlist = new list (sashform, SWT. Border );
Selectlist. setitems (items );
Selectlist. addmouselistener (New mymouselistener (selectlist ));
}
{
// Stack panel on the right
Stacklayout = new stacklayout ();
Rightcom = new composite (sashform, SWT. Border );
Rightcom. setlayout (stacklayout );
Rightpersonalcom = This. createpersonalmsg (rightcom );
Rightcontactcom = This. createcontact (rightcom );

// Set the initialization display panel
Stacklayout. topcontrol = rightpersonalcom;

}
Sashform. setweights (New int [] {1, 3 });
// Sashform. setbounds (20, 20,500,420 );
}
{
// Button panel
Composite buttoncomp = new composite (shell, SWT. None );
Griddata btngriddata = new griddata ();
Btngriddata. horizontalalignment = griddata. end;
Buttoncomp. setlayoutdata (btngriddata );
Rowlayout btnrl = new rowlayout ();
Btnrl. spacing = 20;
Buttoncomp. setlayout (btnrl );

Button enterbtn = new button (buttoncomp, SWT. None );
Enterbtn. settext ("OK ");

Button canclebtn = new button (buttoncomp, SWT. None );
Canclebtn. settext ("cancel ");

Button appbtn = new button (buttoncomp, SWT. None );
Appbtn. settext ("application ");
}

Shell. layout ();
Shell. open ();
While (! Shell. isdisposed ()){
If (! Display. readanddispatch ()){
Display. Sleep ();
}
}
Display. Dispose ();
}
 
/**
* Personal data panel
* @ Param Composite
* @ Return
*/
Private composite createpersonalmsg (composite rightcomposite ){
Composite composite = new composite (rightcomposite, SWT. Border );
Composite. setlayout (New gridlayout (10, false); // the Panel uses the gridlayout layout manager and is divided into six columns.
Label nickname = new label (composite, SWT. None );
Nickname. settext ("nickname :");
Nickname. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 5 ));

Label qqnum = new label (composite, SWT. None );
Qqnum. settext ("account :( bind email account )");
Qqnum. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 5 ));

Text nicktext = new text (composite, SWT. Border );
Nicktext. settext ("baby_nanhai ");
Nicktext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 5 ));

Text numtext = new text (composite, SWT. Border );
Numtext. settext ("545073934 ");
Numtext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 5 ));

Label grade = new label (composite, SWT. None );
Grade. settext ("grade :");
Grade. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Text gradetext = new text (composite, SWT. Border );
Gradetext. settext ("set the image icon here ");
Gradetext. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 9 ));

Label Sign = new label (composite, SWT. None );
Sign. settext ("personalized Signature :");
Sign. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 10 ));

Text signtext = new text (composite, SWT. Border | SWT. Wrap );
Signtext. settext (signtexts );
Signtext. setlayoutdata (this. creategriddata4 (griddata. horizontal_align_fill, 50, 10 ));

Label sex = new label (composite, SWT. None );
Sex. settext ("Gender :");
Sex. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Label age = new label (composite, SWT. None );
Age. settext ("Age :");
Age. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Label birth = new label (composite, SWT. None );
Birth. settext ("birthday :");
Birth. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 7 ));

Combo sexcombo = new combo (composite, SWT. None );
Sexcombo. setitems (sexs );
Sexcombo. Select (0 );
Sexcombo. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Text agetext = new text (composite, SWT. Border );
Agetext. settext ("0 ");
Agetext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Combo birtmonthscombo = new combo (composite, SWT. None );
Birtmonthscombo. setitems (months );
Birtmonthscombo. Select (0 );
Birtmonthscombo. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 3 ));

Combo birtdayscombo = new combo (composite, SWT. None );
Birtdayscombo. setitems (days );
Birtdayscombo. Select (0 );
Birtdayscombo. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 3 ));
Birtdayscombo. setenabled (false );

Label shengxiao = new label (composite, SWT. None );
Shengxiao. settext ("Zodiac :");
Shengxiao. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Label blood = new label (composite, SWT. None );
Blood. settext ("blood type :");
Blood. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Label starsign = new label (composite, SWT. None );
Starsign. settext ("constellation :");
Starsign. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 7 ));

Combo shengxiaocombo = new combo (composite, SWT. None );
Shengxiaocombo. setitems (shengxiaos );
Shengxiaocombo. Select (0 );
Shengxiaocombo. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Combo bloodcombo = new combo (composite, SWT. None );
Bloodcombo. setitems (bloods );
Bloodcombo. Select (0 );
Bloodcombo. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Combo starcombo = new combo (composite, SWT. None );
Starcombo. setitems (stars );
Starcombo. Select (0 );
Starcombo. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 7 ));




Return composite;
}
 
/**
* More data panel Editor
* @ Param rightcomposite
* @ Return
*/
Private composite createcontact (composite rightcomposite ){
Composite composite = new composite (rightcomposite, SWT. Border );
Composite. setlayout (New gridlayout (2, false ));

Final label authority = new label (composite, SWT. None );
Authority. settext ("select the display range of the following materials :");
Authority. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final label mobile = new label (composite, SWT. None );
Mobile. settext ("cell phone :");
Mobile. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Combo authoritycombo = new combo (composite, SWT. None );
Authoritycombo. setitems (authoritys );
Authoritycombo. Select (2 );
Authoritycombo. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final text mobiletext = new text (composite, SWT. Border );
Mobiletext. settext ("-");
Mobiletext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Final label telephone = new label (composite, SWT. None );
Telephone. settext ("Tel :");
Telephone. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final label email = new label (composite, SWT. None );
Email. settext ("Email :");
Email. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Final text telephonetext = new text (composite, SWT. Border );
Telephonetext. settext ("-");
Telephonetext. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final text emailtext = new text (composite, SWT. Border );
Emailtext. settext ("-");
Emailtext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Final label job = new label (composite, SWT. None );
Job. settext ("Occupation :");
Job. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final label college = new label (composite, SWT. None );
College. settext ("Graduate School :");
College. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Final text jobtext = new text (composite, SWT. Border );
Jobtext. settext ("-");
Jobtext. setlayoutdata (this. creategriddata2 (griddata. horizontal_align_fill, 1 ));

Final text collegetext = new text (composite, SWT. Border );
Collegetext. settext ("-");
Collegetext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 1 ));

Final label page = new label (composite, SWT. None );
Page. settext ("personal homepage :");
Page. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Final text pagetext = new text (composite, SWT. Border );
Pagetext. settext ("-");
Pagetext. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Final label introduce = new label (composite, SWT. None );
Introduce. settext ("personal note :");
Introduce. setlayoutdata (this. creategriddata2 (griddata. fill_horizontal, 2 ));

Final text introducetext = new text (composite, SWT. Border );
Introducetext. settext ("-");
Introducetext. setlayoutdata (this. creategriddata4 (griddata. fill_horizontal, 70, 2 ));

Return composite;
}
 
/**
*
* @ Param horizontalspan
* @ Return
*/
Private griddata creategriddata1 (INT horizontalspan ){
Griddata = new griddata ();
Griddata. horizontalspan = horizontalspan;
// Griddata. verticalspan = verticalspan;
Return griddata;
}
 
/**
* Create griddata
* @ Param stytle Style
* @ Param horizontalspan merge Columns
* @ Return
*/
Private griddata creategriddata2 (INT stytle, int horizontalspan ){
Griddata = new griddata (stytle );
Griddata. horizontalspan = horizontalspan;
// Griddata. horizontalalignment = griddata. Center;
Return griddata;
}
 
/**
* Create griddata
* @ Param stytle Style
* @ Param horizontalspan merge Columns
* @ Param verticalspan merge rows
* @ Return
*/
Private griddata creategriddata3 (INT stytle, int horizontalspan, int verticalspan ){
Griddata = new griddata (stytle );
Griddata. horizontalspan = horizontalspan;
Griddata. verticalspan = verticalspan;

Return griddata;
}
 
/**
*
* @ Param stytle
* @ Param heighthint
* @ Param horizontalspan
* @ Return
*/
Private griddata creategriddata4 (INT stytle, int heighthint, int horizontalspan ){
Griddata = new griddata (stytle );
Griddata. heighthint = heighthint;
Griddata. horizontalspan = horizontalspan;
Return griddata;
}
 
/**
* Click an event
* @ Author Andy Wang
*
*/
Private final class mymouselistener extends mouseadapter {

Private list;
Public mymouselistener (){}
Public mymouselistener (list ){
This. List = List;
}

Public void mousedown (mouseevent e ){
Int selectindex = List. getselectionindex ();
If (selectindex = 0 ){
Stacklayout. topcontrol = rightpersonalcom;
Rightcom. layout ();
} Else {
Stacklayout. topcontrol = rightcontactcom;
Rightcom. layout ();
}
}
}
 
/**
* Main start QQ
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
Try {
Qqpersonalsetwindows QQ = new qqpersonalsetwindows ();
QQ. open ();
} Catch (exception e ){
E. printstacktrace ();
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.