Java – how to add themes to SWT WPF programs?

I want to use WPF on the Windows version of my java application I find it easy to do this with SWT. It also supports WPF resource dictionary XAML (please see this) of SWT elements SWT WPF implementation works well for me, but I can't find out how to put WPF theme on it Some with org eclipse. swt. widgets. The same SWT widgets as buttons have SetData methods, but some of them are like org eclipse. swt. widgets. There is no such method as display The setDate method on the shell also does not set the theme on the whole window

So how to add a theme to the whole window of SWT WPF program?

This is an example code:

import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MenuItem;

public class MainForm {

    protected Shell shell;

    public static void main(String[] args) {
        try {
            MainForm window = new MainForm();
            window.open();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void open() {
        Display display = Display.getDefault();
        createContents();
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }

    protected void createContents() {
        shell = new Shell();
        shell.setData(
                "ResourceDictionary","ExpressionDark.xaml");
        // theme not applied on entire window,just buttons

        shell.setSize(450,300);
        shell.setText("Window Title");

        Button button = new Button(shell,SWT.FLAT);
        button.setText("Button");
        button.setSize(250,50);
        button.setBounds(0,50,250,50);

        Menu menu = new Menu(shell,SWT.BAR);
        shell.setMenuBar(menu);

        MenuItem mntmNewSubmenu = new MenuItem(menu,SWT.CASCADE);
        mntmNewSubmenu.setText("New SubMenu");

        Menu menu_1 = new Menu(mntmNewSubmenu);
        mntmNewSubmenu.setMenu(menu_1);

    }
}

Solution

SWT WPF is no longer supported. Therefore, it is best not to use

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>