A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://plugins.jetbrains.com/docs/intellij/dialog-wrapper.html below:

Dialogs | IntelliJ Platform Plugin SDK

Dialogs DialogWrapper

The DialogWrapper is the base class which is supposed to be used for all modal dialogs (and some non-modal dialogs) shown in IntelliJ Platform.

It provides the following features:

There's also a DSL-like API via DialogBuilder.

Usage

When using the DialogWrapper class for a dialog, follow these required steps:

Optionally:

Dialog Content

Use Kotlin UI DSL to provide the dialog's contents (see samples). Alternatively or when using Java, the DialogWrapper class can be used together with GUI Designer forms. In this case, bind a GUI Designer form to the class extending DialogWrapper, bind the top-level panel of the form to a field and return that field from the createCenterPanel() method.

See Layout topic in UI Guidelines for recommendations on arranging UI controls in dialogs.

Existing dialogs can be inspected at runtime using UI Inspector, for example, to locate the underlying implementation of UI components.

Displaying the Dialog

To display the dialog, call the show() method and then use the getExitCode() method to check how the dialog was closed (see DialogWrapper#OK_EXIT_CODE, CANCEL_EXIT_CODE, CLOSE_EXIT_CODE). The showAndGet() method can be used to combine these two calls.

Customizing Buttons

To customize the buttons displayed in the dialog (replacing the standard OK/Cancel/Help set of buttons), override either the createActions() or createLeftActions() methods. Both of these methods return an array of Swing Action objects. If a button closes the dialog, use DialogWrapperExitAction as the base class for the action.

Use action.putValue(DialogWrapper.DEFAULT_ACTION, true) to set the default button and action.putValue(DialogWrapper.FOCUSED_ACTION, true) to set the focused button.

Input Validation

See also Validation Errors topic in UI Guidelines.

To validate the data entered into the dialog, call initValidation() in the dialog's constructor and override the doValidate() method to perform the actual validation. The method will be called automatically via a timer.

If the currently entered data is valid, return null. Otherwise, return a ValidationInfo object which encapsulates an error message, and an optional component associated with the invalid data. When specifying a component, an error icon will be displayed next to it, and it will be focused when the user tries to invoke the OK action.

Examples

Minimum sample of a DialogWrapper:

public class SampleDialogWrapper extends DialogWrapper { public SampleDialogWrapper() { super(true); // use current window as parent setTitle("Test DialogWrapper"); init(); } @Nullable @Override protected JComponent createCenterPanel() { JPanel dialogPanel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Testing"); label.setPreferredSize(new Dimension(100, 100)); dialogPanel.add(label, BorderLayout.CENTER); return dialogPanel; } }

Show SampleDialogWrapper dialog when user clicks on button:

JButton testButton = new JButton(); testButton.addActionListener(actionEvent -> { if (new SampleDialogWrapper().showAndGet()) { // user pressed OK } });

Kotlin

Dialogs using Kotlin UI DSL:

03 April 2025


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4