在rcp开发中,要自定义对话框,首先要继承org.eclipse.jface.dialogs.Dialog
public class MyDialog extends Dialog
1,定义对话框大小,需要重写getInitialSize方法
[color=gray][b]@Override
protected Point getInitialSize() {
return new Point(540,480);
}[/b][/color]
2,定义对话框界面,需要重写createDialogArea方法.以下是org.eclipse.jface.
dialogs.Dialog的createDialogArea方法的源码,我们可以根据需要在里面添加自己需要的组件
[color=gray][b]protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutD
public class MyDialog extends Dialog
1,定义对话框大小,需要重写getInitialSize方法
[color=gray][b]@Override
protected Point getInitialSize() {
return new Point(540,480);
}[/b][/color]
2,定义对话框界面,需要重写createDialogArea方法.以下是org.eclipse.jface.
dialogs.Dialog的createDialogArea方法的源码,我们可以根据需要在里面添加自己需要的组件
[color=gray][b]protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutD

本文详细介绍了如何在Eclipse RCP开发中自定义对话框,包括继承Dialog类,设置对话框大小,创建界面,定义按钮,管理按钮状态,处理按钮事件以及获取和设置组件值的方法。
最低0.47元/天 解锁文章
3229

被折叠的 条评论
为什么被折叠?



