/*
* Created on 29.10.2004
*/
package de.tutorials;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* @author Darimont
*
*/
public class Test40 {
private Image img;
public static void main(String[] args) {
new Test40().doIt();
}
private void doIt() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test40");
shell.setLayout(new FillLayout());
LoginPanel lp = new LoginPanel(shell, SWT.BORDER);
shell.open();
shell.setSize(411, 108); //Größe des Bildes (w,h)
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
class LoginPanel extends Composite {
public LoginPanel(Composite comp, int arg) {
super(comp, arg);
img = new Image(Display.getCurrent(), "c:/tutv4.jpg");
setLayout(new GridLayout(2, false));
Label label = new Label(this, SWT.NONE);
label.setText("User: ");
Text txtUserName = new Text(this, SWT.NONE);
label = new Label(this, SWT.NONE);
label.setText("Password: ");
Text txtPassword = new Text(this, SWT.NONE);
txtPassword.setEchoChar('*');
Button btnLogin = new Button(this, SWT.PUSH);
btnLogin.setText("login");
addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
System.out.println("AAA");
GC gc = new GC(LoginPanel.this);
gc.drawImage(img, 0, 0);
gc.dispose();
}
});
}
public void dispose() {
if (img != null)
img.dispose();
super.dispose();
}
}
}