在 swt/jface 对话框中显示图像的提示

发布于 2024-10-11 00:13:03 字数 62 浏览 8 评论 0原文

我正在寻找在 SWT/JFace 对话框中显示图像的提示/教程。

有人可以指出我正确的方法吗?

I'm looking for tips/tutorials for displaying an image in a SWT/JFace dialog box.

Can someone please point me to the right way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抱着落日 2024-10-18 00:13:03

查看官方教程

如果可点击:

Image image = new Image(display,
    ShellWithButtonShowingEclipseLogo.class.getResourceAsStream(
      "yourpicture"));
Button button = new Button(shell,SWT.PUSH);
button.setImage(image); 

如果不可点击,则可以使用标签而不是按钮

Take a look at the official tutorial.

If it is clickable:

Image image = new Image(display,
    ShellWithButtonShowingEclipseLogo.class.getResourceAsStream(
      "yourpicture"));
Button button = new Button(shell,SWT.PUSH);
button.setImage(image); 

If it is not clickable then you can use Label instead of Button.

另类 2024-10-18 00:13:03

从你的问题我了解到你正在试图展示
对话框标题区域中的图像。

您可以使用“setTitleImage(Image image)”函数
您的主类(扩展 Dialog 的类)

示例:

class DemoDialog extends TitleAreaDialog {

    public DemoDialog(Shell parentShell) {
        super(parentShell);
    }

    protected Control createDialogArea(Composite parent) {
        setTitle("Demo dialog...");
        setTitleImage(ImageObject) // Image to be displayed in your Dialog
    }

}

From your question i understood that you are trying to display
an image in the title area of the daialog Box.

You can make use of the "setTitleImage(Image image)" function in
your main class (class which extends the Dialog )

example:

class DemoDialog extends TitleAreaDialog {

    public DemoDialog(Shell parentShell) {
        super(parentShell);
    }

    protected Control createDialogArea(Composite parent) {
        setTitle("Demo dialog...");
        setTitleImage(ImageObject) // Image to be displayed in your Dialog
    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文