# INTViewer APIs For The INTViewer Desktop

The INTViewer desktop is loaded at startup. It contains menu items, toolbar and windows. Notifications are displayed on the bottom right of the desktop.

### Desktop Area

To get the dimensions of the desktop area not used by the top components (highlighted in red in the snapshot below), use:

```
   java.awt.Dimension dim = com.interactive.intviewerapi.windows.IWindowManager.Factory.getInstance().getDesktopSize();
```

This method is valid only in the context of the legacy FRAMES window system (see [Overview of API changes in INTViewer 5.2](/solutions/intviewer/intviewer-platform-and-modules/overview-of-api-changes-in-intviewer-5-2))

### Cursor

To change the cursor to an hourglass for the entire desktop:

```
   org.openide.windows.WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
```

and back

```
    org.openide.windows.WindowManager .getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
```

To change the cursor to an hourglass for only a window:

```
   AbstractWindow window = (AbstractWindow) win;
   window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
```

and back

```
   AbstractWindow window = (AbstractWindow) win;
   window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
```

### Windows

To organize windows inside the INTViewer desktop, refer to the [Finding and organizing windows](/solutions/intviewer/intviewer-apis-for-windows/finding-and-organizing-windows) article.

To organize top components along the INTViewer desktop, refer to the [Creating and Manipulating TopComponent Windows](/solutions/intviewer/intviewer-apis-for-windows/creating-a-topcomponent-window) article.

### Menu Items

The INTViewer platform leverages the Netbeans menu system. Refer to the [Adding a Menu Walkthrough](/solutions/intviewer/intviewer-tutorial/using-netbeans-swing-components-walkthroughs/adding-a-menu-walkthrough) and the [Adding a Menu Item Walkthrough](/solutions/intviewer/intviewer-tutorial/using-netbeans-swing-components-walkthroughs/adding-a-menu-item-walkthrough) articles to add your own desktop menus.

### Toolbars and Undo/Redo

The INTViewer platform leverages the Netbeans toolbar system. Refer to the [Customizing the Toolbar Walkthrough](/solutions/intviewer/intviewer-tutorial/using-netbeans-swing-components-walkthroughs/customizing-the-toolbar-walkthrough) to add your own toolbar.

INTViewer provides an API to manipulate the undo/redo stack available from the Undo and Redo buttons.

To create an action that can be undone, implement the com.interactive.intviewerapi.undoredo.IUndoRedo interface.

To post an action to the undo/redo stack, use the com.interactive.intviewerapi.undoredo.IUndoRedoManager singleton.

In this example, MyEdit implements IUndoRedo:

```
            MyEdit edit = new MyEdit(...);
           IUndoRedoManager undoRedoManager = IUndoRedoManager.Factory.getInstance();
           undoRedoManager.postUndoRedo(edit);
```

### Startup

You can force the execution of an action upon startup. Just implement a NetBeans org.openide.util.actions.SystemAction and register it in the layer.xml file.

Example:

CHECKJAVASTARTUPACTION.JAVA

```
package com.interactive.intviewer.control;
import com.interactive.intviewer.util.JavaVersionUtil;
import com.interactive.intviewerapi.util.NotificationManager;
import java.awt.event.ActionEvent;
import org.openide.util.HelpCtx;
import org.openide.util.actions.SystemAction;
public class CheckJavaStartupAction extends SystemAction {
    @Override
    public String getName() {
        return this.getClass().getName();
    }
    @Override
    public HelpCtx getHelpCtx() {
        return HelpCtx.DEFAULT_HELP;
    }
    @Override
    public void actionPerformed(ActionEvent ae) {
        if (JavaVersionUtil.isSupported()) {
            return;
        }
        NotificationManager.getDefault().showMessageNotification("The Java Runtime currently in use is not supported", NotificationManager.WARNING, true);
    }
}
```

LAYER.XML

```xml
<filesystem>
    <folder name="StartupActions">
        <file name="com-interactive-intviewer-control-CheckJavaStartupAction.instance"/>
    </folder>
</filesystem>
```

Startup actions that are built-in can be removed using the instance_hidden syntax.

For example, the CheckJavaStartupAction startup action notifies users when their version is Java is not supported. It is plugged this way:

```xml
    <folder name="StartupActions">
        <file name="com-interactive-intviewer-startup-CheckJavaStartupAction.instance">
            <attr name="position" intvalue="400"/>
        </file>
    </folder>
```

It can be unplugged with this syntax:

```xml
    <folder name="StartupActions">
        <file name="com-interactive-intviewer-startup-CheckJavaStartupAction.instance_hidden" />
    </folder>
```

To insert code at various points of the application's lifecycle, you can also extend the org.openide.modules.ModuleInstall class from the NetBeans platform (see [platform.netbeans.org/tutorials/nbm-runtime-container.html](https://platform.netbeans.org/tutorials/nbm-runtime-container.html) for an example).

### Exit

You can force the execution of an action upon exit. Just implement a NetBeans org.openide.util.actions.SystemAction and register it in the layer.xml file.

CHECKBACKGROUNDTASKSEXITACTION.JAVA

```
package com.interactive.intviewer.control;
import com.interactive.intviewer.TaskCounter;
import com.interactive.intviewerapi.util.DialogManager;
import java.awt.event.ActionEvent;
import org.openide.util.HelpCtx;
import org.openide.util.actions.SystemAction;
public class CheckBackgroundTasksExitAction extends SystemAction {
    @Override
    public String getName() {
        return this.getClass().getName();
    }
    @Override
    public HelpCtx getHelpCtx() {
        return HelpCtx.DEFAULT_HELP;
    }
    @Override
    public void actionPerformed(ActionEvent ae) {
        if (TaskCounter.getInstance().value() > 0) {
            int result = DialogManager.getDefault().showConfirmDialog("Exiting application will terminate one or more processes.\n Are you sure you want to exit?", "Exit Application", DialogManager.YES_NO_OPTION);
            if (!(result == DialogManager.YES_OPTION)) {
                throw new IllegalStateException("Exit cancelled");
            }
        }
    }
}
```

LAYER.XML

```xml
<filesystem>
    <folder name="ExitActions">
        <file name="com-interactive-intviewer-control-CheckBackgroundTasksExitAction.instance">
            <attr name="position" intvalue="200"/>
        </file>
    </folder>
</filesystem>
```

### Notifications

You can display a notification on the bottom right of the screen using com.interactive.intviewerapi.util.NotificationManager.

Example:

```
        NotificationManager.getDefault().showMessageNotification("The Java Runtime currently in use is not supported", NotificationManager.WARNING, true);
```

### Status bar

You can show a message in the status bar on the bottom left of the screen using com.interactive.intviewerapi.windows.IWindowManager.

Example:

```
com.interactive.intviewerapi.windows.IWindowManager.Factory.getInstance().showMessage("This is my message");
```

### Nodes

Contextual menu items in nodes can be [customized](/solutions/intviewer/intviewer-apis-for-the-intviewer-desktop/customizing-menu-items-in-nodes).

### Options

You will need to add the "Options Dialog and SPI" **Module Dependency**. This is a NetBeans module.

To open the **Tools** -> **Options** dialog at a specified tab:

```
   import org.netbeans.api.options.OptionsDisplayer;
   String path = "Gui/Desktop";
   OptionsDisplayer.getDefault().open(path);
```

To open the "Proxy" panel, use this NetBeans command:

```
OptionsDisplayer.getDefault().open("Proxy);
```