Shell in Shell ohne Inhalt....

Ronin-Jay

Erfahrenes Mitglied
Hallo,
ich habe mal wieder eine kleines Problem, welches bestimmt in Kürze gelöst werden kann. Allerdings sehe ich die Lösung nicht.

Ich habe eine Shell die geöffnet wird. Darin öffnet sich dann eine weitere zwecks Login. Nur leider stellt die 2. Shell keinen Inhalt dar, sprich ist leer, obwohl etwas angezeigt werden müßte. Ich habe mir einen Beispielaufbau auf einem anderen Projekt von mir genommen. Dort t die Darstellung wunderbar - hier leider nur, wenn ich bei jedem Element ein ELEMENT.pack(); einfüge....

Java:
private void doLogin(Shell parentShell){
		//shell anlegen
		final Shell loginSh = new Shell(parentShell, SWT.APPLICATION_MODAL);
		
		//1.Reihe: Ueberschrift
		Label header = new Label(loginSh, SWT.CENTER);
		GridData headerGD = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
		headerGD.horizontalSpan = 2;
		header.setLayoutData(headerGD);
		header.setForeground(new Color(Display.getCurrent(), 18,34,234));
		header.setFont(new Font(Display.getCurrent(), "Arial", 12, 3));
		header.setText("JDCalendar - LOGIN");

		//2.Reihe: hor. Linie
		Label line = new Label(loginSh, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.CENTER);
		GridData lineGD = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
		lineGD.horizontalSpan = 2;
		lineGD.widthHint = 190;
		line.setLayoutData(lineGD);

		//3.Reihe: Username + Textfeld
		Label username = new Label(loginSh, SWT.LEFT);
		username.setText("Username:");
		final Text usernameText = new Text(loginSh, SWT.LEFT | SWT.BORDER);
		GridData usernameTextGD = new GridData();
		usernameTextGD.widthHint = 100;
		usernameText.setLayoutData(usernameTextGD);
		usernameText.setFocus();

		//4.Reihe: Passwort + Textfeld
		Label password = new Label(loginSh, SWT.LEFT);
		password.setText("Passwort:");
		final Text passwordText = new Text(loginSh, SWT.NONE | SWT.BORDER);
		GridData passwordTextGD = new GridData();
		passwordTextGD.widthHint = 100;
		passwordText.setLayoutData(passwordTextGD);
		passwordText.setEchoChar('*');

		//Listener auf Enter
		usernameText.addListener (SWT.DefaultSelection, new Listener () {
			public void handleEvent (Event e) {
				passwordText.setFocus();
			}
		});
		passwordText.addListener (SWT.DefaultSelection, new Listener () {
			public void handleEvent (Event e) {

			}
		});

		//5.Reihe: Linie
		line = new Label(loginSh, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.CENTER);
		line.setLayoutData(lineGD);

		//6.Reihe: Button
		//Button ok
		Button ok = new Button(loginSh, SWT.CENTER);
		ok.setText("&OK");
		ok.setLayoutData(getButtonGridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
		ok.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				loginSh.close();
				enableButton();
			}
			public void widgetDefaultSelected(SelectionEvent e) {
			}
		});
		ok.pack();

		//Button abbruch
		Button ca = new Button(loginSh, SWT.CENTER);
		ca.setText("&Cancel");
		ca.setLayoutData(getButtonGridData(GridData.HORIZONTAL_ALIGN_END));
		ca.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				loginSh.close();
			}
		});
		
		loginSh.pack();
		loginSh.open();

		//LOGIN in der Mitte der Toplevel oeffnen
		Rectangle displayBounds = display.getBounds();
		Point dialogSize = loginSh.getSize();
		loginSh.setLocation(
				displayBounds.x + (displayBounds.width - dialogSize.x) / 2,
				displayBounds.y + (displayBounds.height - dialogSize.y) / 2
		);

		while (!loginSh.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
	}//doLogin

In diesem Codeausschnitt wird also nur der OK-Button angezeigt... :confused: Nicht mal die Shell ist zu sehen, obwohl es so aussehen sollte, wie auf dem angehängten Bild
loginiz8.png
.
 

Neue Beiträge

Zurück