Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Splash screen and own dialog window
| |
Re: Splash screen and own dialog window [message #461741 is a reply to message #459601] |
Thu, 29 September 2005 07:42 |
udayms Messages: 23 Registered: July 2009 |
Junior Member |
|
|
Dont know if this is too late.... but, this is what i am using for the same effect...
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class LoginDialog {
private static Text txt_Password;
private static Text txt_Username;
public static void main(String[] args) {
final Display display = new Display();
//Shell must be created with style SWT.NO_TRIM
final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
shell.setBackground(SWTResourceManager.getColor(0, 0, 0));
final FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 1;
shell.setLayout(fillLayout);
final Composite composite = new Composite(shell, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginHeight = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.horizontalSpacing = 0;
composite.setLayout(gridLayout);
composite.setBackground(SWTResourceManager.getColor(255, 255, 255));
final Label img_Label = new Label(composite, SWT.NONE);
img_Label.setLayoutData(new GridData(195, 181));
final Image img = new Image(display, "resources/images/img_login.gif");
img_Label.setImage(img);
final Composite cmp_Login = new Composite(composite, SWT.NONE);
cmp_Login.setBackground(SWTResourceManager.getColor(255, 255, 255));
final RowLayout rowLayout = new RowLayout();
rowLayout.fill = true;
cmp_Login.setLayout(rowLayout);
final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
gridData.widthHint = 196;
cmp_Login.setLayoutData(gridData);
final CLabel clbl_UserLogin = new CLabel(cmp_Login, SWT.NONE);
final RowData rowData = new RowData();
rowData.width = 180;
clbl_UserLogin.setLayoutData(rowData);
clbl_UserLogin.setFont(SWTResourceManager.getFont("", 8, SWT.BOLD));
clbl_UserLogin.setBackground(SWTResourceManager.getColor(255 , 255, 255));
clbl_UserLogin.setText("User Login");
final CLabel clbl_Username = new CLabel(cmp_Login, SWT.NONE);
final RowData rowData_1 = new RowData();
rowData_1.width = 180;
clbl_Username.setLayoutData(rowData_1);
clbl_Username.setBackground(SWTResourceManager.getColor(255, 255, 255));
clbl_Username.setText("Username");
txt_Username = new Text(cmp_Login, SWT.BORDER);
final RowData rowData_2 = new RowData();
rowData_2.width = 170;
txt_Username.setLayoutData(rowData_2);
final CLabel clbl_Password = new CLabel(cmp_Login, SWT.NONE);
final RowData rowData_3 = new RowData();
rowData_3.width = 180;
clbl_Password.setLayoutData(rowData_3);
clbl_Password.setBackground(SWTResourceManager.getColor(255, 255, 255));
clbl_Password.setText("Password");
txt_Password = new Text(cmp_Login, SWT.BORDER);
final RowData rowData_4 = new RowData();
rowData_4.width = 170;
txt_Password.setLayoutData(rowData_4);
txt_Password.setEchoChar('*');
final Composite cmp_ButtonBar = new Composite(cmp_Login, SWT.NONE);
final RowData rowData_5 = new RowData();
rowData_5.height = 38;
rowData_5.width = 185;
cmp_ButtonBar.setLayoutData(rowData_5);
cmp_ButtonBar.setLayout(new FormLayout());
cmp_ButtonBar.setBackground(SWTResourceManager.getColor(255, 255, 255));
final Button btn_login = new Button(cmp_ButtonBar, SWT.FLAT);
final FormData formData = new FormData();
formData.bottom = new FormAttachment(0, 28);
formData.top = new FormAttachment(0, 5);
formData.right = new FormAttachment(100, -3);
formData.left = new FormAttachment(100, -40);
btn_login.setLayoutData(formData);
btn_login.setText("Login");
btn_login.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
shell.close();
}
});
final CLabel clbl_Message = new CLabel(cmp_Login, SWT.NONE);
clbl_Message.setAlignment(SWT.RIGHT);
clbl_Message.setFont(SWTResourceManager.getFont("Verdana", 7, SWT.NONE));
clbl_Message.setBackground(SWTResourceManager.getColor(255, 255, 255));
final RowData rowData_6 = new RowData();
rowData_6.width = 188;
clbl_Message.setLayoutData(rowData_6);
clbl_Message.setText("xxxxxx");
Region region = new Region();
Rectangle pixel = new Rectangle(1, 1, 388, 180);
region.add(pixel);
shell.setRegion(region);
//add ability to move shell around
Listener l = new Listener() {
Point origin;
public void handleEvent(Event e) {
switch (e.type) {
case SWT.MouseDown:
origin = new Point(e.x, e.y);
break;
case SWT.MouseUp:
origin = null;
break;
case SWT.MouseMove:
if (origin != null) {
Point p = display.map(shell, null, e.x, e.y);
shell.setLocation(p.x - origin.x, p.y - origin.y);
}
break;
}
}
};
composite.addListener(SWT.MouseDown, l);
composite.addListener(SWT.MouseUp, l);
composite.addListener(SWT.MouseMove, l);
img_Label.addListener(SWT.MouseDown, l);
img_Label.addListener(SWT.MouseUp, l);
img_Label.addListener(SWT.MouseMove, l);
shell.setLocation(320,290);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
region.dispose();
display.dispose();
}
}
|
|
|
Goto Forum:
Current Time: Fri Mar 29 01:53:09 GMT 2024
Powered by FUDForum. Page generated in 0.03760 seconds
|