JFace-Dialog
Komplexere Dialoge macht der JFace-Dialog möglich.
JFace-Dialog
package SWTDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
public class JFaceDialogApp extends ApplicationWindow{
public JFaceDialogApp() {
super(null);
}
@Override
JFaceDialog jFaceDialog = new JFaceDialog((Shell) parent);
System.
out.
println("Ergebnis: "+ (jFaceDialog.
open())); return parent;
}
public void run() {
setBlockOnOpen(true);
open();
Display.getDefault().dispose();
}
public static void main
(String[] args
) { new JFaceDialogApp().run();
}
}
package SWTDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
public class JFaceDialog extends TitleAreaDialog{
public JFaceDialog(Shell parentShell) {
super(parentShell);
}
/**
* Anlegen des Titelbereichs
*/
@Override
Control contents
= super.
createContents(parent
);
setTitleImage(getShell().getDisplay().
getSystemImage(SWT.ICON_WORKING));
setMessage("Blabla Message Bla bla Informaion",
IMessageProvider.INFORMATION);
setTitle("Blabla Dialog");
return contents;
}
/**
* Buttons erzeugen
*/
protected void createButtonsForButtonBar
(Composite parent
) { createButton(parent,
IDialogConstants.OK_ID,
IDialogConstants.OK_LABEL,
true);
createButton(parent,
IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL,
false);
createButton(parent,
IDialogConstants.HELP_ID,
IDialogConstants.HELP_LABEL,
false);
}
@Override
return contents;
}
/**
* Ereignisbehandlung
*/
@Override
protected void buttonPressed(int buttonId) {
// TODO Auto-generated method stub
super.buttonPressed(buttonId);
close();
}
}
Pages: 1 2 3 4 5 6 7