How to add a MainWindow to a Desktop App?

Hi:

I’m trying to implement a Desktop version of my app, including a MainWindow. When I generate a MainWindow and try to compile it, I get:

:rentals-desktop:compileJava/home/eraskin/studio-projects/listrental/modules/desktop/src/com/company/listrental/desktop/screens/ExtAppMainWindow.java:3: error: package com.haulmont.cuba.web.app.mainwindow does not exist
import com.haulmont.cuba.web.app.mainwindow.AppMainWindow;
                                           ^
/home/eraskin/studio-projects/listrental/modules/desktop/src/com/company/listrental/desktop/screens/ExtAppMainWindow.java:5: error: cannot find symbol
public class ExtAppMainWindow extends AppMainWindow {
                                      ^
  symbol: class AppMainWindow
2 errors
 FAILED

It appears that the template only works for Web mode.

How do I create a MainWindow for Desktop?

Also – as an aside – a slight problem in the documentation for 6.6. At thte top of section 4.5.9 (Desktop Client Specifics), it appears an image is not displaying:

4.5.9. Desktop Client Specifics

Implementation of the generic user interface in the Desktop Client block is based on Java Swing. The main classes available in the desktop client infrastructure are described below..Classes of the Desktop Client Infrastructure image::DesktopClientInfrastructure.png[align="center"]

Can you get the picture to appear?

Thanks!

Eric

Hi!

Unfortunately, MainWindow is not supported for Desktop. And we do not plan to add this feature in the near future.

That’s unfortunate.

At the moment, you could extend com.haulmont.cuba.desktop.TopLevelFrame class and use your own implementation based on Java Swing.


public class MyAppMainFrame extends TopLevelFrame {
    public MyAppMainFrame(String applicationTitle) {
        super(applicationTitle);
    }
}

And override App.createMainFrame method:


public class App extends com.haulmont.cuba.desktop.App {

// ...

    @Override
    protected TopLevelFrame createMainFrame() {
        return new MyAppMainFrame(getApplicationTitle());
    }
}

In MyAppMainFrame class you can use CUBA services and entities, but cannot use UI components. You can use only Java Swing UI components, usually it is enough to create a simple UI for main window, for instance to show some charts or open new window after login.

A post was split to a new topic: How to develop Desktop application with Main window