JFace/SWT:更改 InputDialog 中按钮的标签
我想创建一个带有“确定/取消”按钮的自定义标签的输入对话框。我正在使用 org.eclipse.jface.dialogs.InputDialog。
我尝试覆盖按钮创建方法:
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
getButton(IDialogConstants.OK_ID).setText(myOkText);
getButton(IDialogConstants.CANCEL_ID).setText(myCancelText);
}
它有效,但按钮没有调整大小(并且自定义文本结果被裁剪)。
我想在这里设置文本已经太晚了,因为布局管理器已经决定了按钮的大小,并且无法告诉它重新计算......是这样吗?
正确的做法是什么?
I want to create an InputDialog with custom labels for the OK/Cancel buttons. I'm using org.eclipse.jface.dialogs.InputDialog.
I tried to override the button creation method:
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
getButton(IDialogConstants.OK_ID).setText(myOkText);
getButton(IDialogConstants.CANCEL_ID).setText(myCancelText);
}
and it works, but the buttons are not resized (and the custom text results cropped).
I guess it's too late to set the text here, because the layout manager has already decided the button size and one cannot tell it to recompute... Is that so?
What is the correct way ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
try this
尝试用这种方式..
try in this way..