Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Eclipse SWT

Empfohlene Antworten

Hallo zusammen,

Ich möchte in einer SWT Anwedung per Button Click ein neues Fenster einblenden, indem ein Textfeld und ein schließen Button abgebildet ist.

Wenn ich auf den Knopf drücke erscheint leider nur eine Leere Shell (ohne Text, Button)...

Weiss jemand wo mein Fehler liegt?


// schnipp...
oButton.addMouseListener( new MouseAdapter()
{
public void mouseDown( MouseEvent e)
{
GridLayout oLayout = new GridLayout();
GridData oGridData = new GridData();

final Shell oShell = new Shell();
oShell.setText( "Eingabe-Maske");
oShell.setLayout( oLayout);

oGridData.heightHint = 200;
oGridData.widthHint = 200;
oShell.setLayoutData(oGridData);

// Create a composite to hold the children
final Composite oComposite = new Composite( oShell, SWT.NONE);

// Text composite
final Text oTextarea = new Text( oComposite, SWT.MULTI);

oGridData = new GridData();
oGridData.heightHint = 150;
oGridData.widthHint = 200;
oTextarea.setLayoutData( oGridData);

// Button composite
final Button oButton = new Button( oComposite, SWT.PUSH);

oGridData = new GridData();
oGridData.heightHint = 50;
oGridData.widthHint = 50;
oButton.setLayoutData( oGridData);

oButton.addMouseListener( new MouseAdapter(){
public void mouseDown(MouseEvent e) {
oText.setText( oTextarea.getText());
oShell.dispose();
}
});

oShell.open();
}
});
// schnapp...
[/PHP]

Gruß,

Markus

PS: Das ganze befindet sich in einem Eclipse Plugin...

Servus,

probier mal, der Shell ein FillLayout zu geben. Dann wird das Composite darin so gross gemacht wie die Shell. Dann dem Composite noch eine Hintergrundfarbe geben, dann siehst Du, wo was angezeigt wird.

BTW, wieso das Composite? Gib den Widgets doch die Shell als Parent.

Peter

BTW, wieso das Composite? Gib den Widgets doch die Shell als Parent.

Gute Frage...

Nachdem ich die Shell direkt als Parent genommen habe gings auch komischerweise direkt..

Naja, dankeschön!

Gruß,

Markus

Du hast der Shell ja auch das Layout gegeben, dem Composite aber nicht. Deshalb wurde dort das Standardlayout verwendet. Welches das ist, kann ich Dir aber aus dem Stegreif nicht sagen.

Das setLayoutData bei der Shell bringt übrigens nichts, da die Shell ja nicht im Layout ihres Parents liegt.

Peter

Super Tipps, danke!

Gruß,

Markus

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.