Java Code Examples for java.awt.Dialog

The following examples show how to use java.awt.Dialog. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   Source File: SplashUISupport.java    License: Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of ColorChooser */
public ColorComboBox() {
    super(content);
    setRenderer(new Renderer());
    setEditable(true);
    setEditor(new Renderer());
    setSelectedItem(new Value(null, null));
    addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            if (getSelectedItem() == CUSTOM_COLOR) {
                Color c = JColorChooser.showDialog(
                        SwingUtilities.getAncestorOfClass
                        (Dialog.class, ColorComboBox.this),
                        loc("SelectColor"), // NOI18N
                        null
                        );
                setColor(c);
            }
            ColorComboBox.this.firePropertyChange(PROP_COLOR, null, null);
        }
    });
}
 
Example 2
Source Project: triplea   Source File: PbfSetupPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void createComponents() {
  final JScrollPane scrollPane = new JScrollPane(localPlayerPanel);
  localPlayerPanel.addHierarchyListener(
      e -> {
        final Window window = SwingUtilities.getWindowAncestor(localPlayerPanel);
        if (window instanceof Dialog) {
          final Dialog dialog = (Dialog) window;
          if (!dialog.isResizable()) {
            dialog.setResizable(true);
            dialog.setMinimumSize(new Dimension(700, 700));
          }
        }
      });
  localPlayerSelection.addActionListener(
      e ->
          JOptionPane.showMessageDialog(
              PbfSetupPanel.this,
              scrollPane,
              "Select Local Players and AI's",
              JOptionPane.PLAIN_MESSAGE));
}
 
Example 3
public static void main(String[] args) {

        final Frame frame = new Frame("Test");
        frame.setSize(400, 400);
        frame.setBackground(FRAME_COLOR);
        frame.setVisible(true);

        final Dialog modalDialog = new Dialog(null, true);
        modalDialog.setTitle("Modal Dialog");
        modalDialog.setSize(400, 200);
        modalDialog.setBackground(DIALOG_COLOR);
        modalDialog.setModal(true);

        new Thread(new Runnable() {

            @Override
            public void run() {
                runTest(modalDialog, frame);
            }
        }).start();

        modalDialog.setVisible(true);
    }
 
Example 4
Source Project: netbeans   Source File: MessageAuthenticationProfile.java    License: Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new MessageAuthentication(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 5
Source Project: NBANDROID-V2   Source File: AndroidCustomizerProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void showCustomizer() {
    Dialog dialog = ProjectCustomizer.createCustomizerDialog(
            //Path to layer folder:
            CUSTOMIZER_FOLDER_PATH,
            //Lookup, which must contain, at least, the Project:
            Lookups.fixed(project),
            //Preselected category:
            "",
            //OK button listener:
            new OKOptionListener(),
            //HelpCtx for Help button of dialog:
            null);
    dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName());
    dialog.setVisible(true);
}
 
Example 6
Source Project: netbeans   Source File: WindowBuilders.java    License: Apache License 2.0 6 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JRootPane.class.getName())) {
        return new JRootPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JDesktopPane.class.getName())) {
        return new JDesktopPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JLayeredPane.class.getName())) {
        return new JLayeredPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Frame.class.getName())) {
        return new FrameBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Dialog.class.getName())) {
        return new DialogBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JInternalFrame.class.getName())) {
        return new JInternalFrameBuilder(instance, heap);
    }
    return null;
}
 
Example 7
Source Project: openjdk-8-source   Source File: JOptionPane.java    License: GNU General Public License v2.0 6 votes vote down vote up
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
 
Example 8
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 9
Source Project: visualvm   Source File: ProfilerSessions.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static ProfilerFeature selectFeature(Set<ProfilerFeature> features, String actionName) {
    UI ui = UI.selectFeature(features);

    HelpCtx helpCtx = new HelpCtx("SelectFeatureDialog.HelpCtx"); // NOI18N // TODO: should have a special one?
    String caption = actionName == null ? Bundle.ProfilerSessions_selectFeature() : actionName;
    DialogDescriptor dd = new DialogDescriptor(ui, caption, true, new Object[]
                                             { DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION },
                                               DialogDescriptor.OK_OPTION, DialogDescriptor.BOTTOM_ALIGN,
                                               helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    
    ProfilerFeature ret = dd.getValue() == DialogDescriptor.OK_OPTION ? ui.selectedFeature() : null;
    
    dd.setMessage(null); // Do not leak because of WindowsPopupMenuUI.mnemonicListener
    
    return ret;
}
 
Example 10
Source Project: jdk8u_jdk   Source File: JOptionPane.java    License: GNU General Public License v2.0 6 votes vote down vote up
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
 
Example 11
public static void main(String[] args) {

        final Frame frame = new Frame("Test");
        frame.setSize(400, 400);
        frame.setBackground(FRAME_COLOR);
        frame.setVisible(true);

        final Dialog modalDialog = new Dialog(null, true);
        modalDialog.setTitle("Modal Dialog");
        modalDialog.setSize(400, 200);
        modalDialog.setBackground(DIALOG_COLOR);
        modalDialog.setModal(true);

        new Thread(new Runnable() {

            @Override
            public void run() {
                runTest(modalDialog, frame);
            }
        }).start();

        modalDialog.setVisible(true);
    }
 
Example 12
Source Project: netbeans   Source File: OutputPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void targetsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_targetsButtonActionPerformed
    UndoCounter undoCounter = new UndoCounter();
    model.addUndoableEditListener(undoCounter);

    TargetsPanel targetsPanel = new TargetsPanel(output); //NOI18N
    DialogDescriptor dlgDesc = new DialogDescriptor(targetsPanel, 
            NbBundle.getMessage(InputPanel.class, "LBL_Targets_Panel_Title")); //NOI18N
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);
    
    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    } else {
        SecurityPolicyModelHelper.getInstance(PolicyModelHelper.getConfigVersion(binding)).setTargets(output, targetsPanel.getTargetsModel());            
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 13
Source Project: NBANDROID-V2   Source File: SdksCustomizer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Shows platforms customizer
 *
 * @param platform which should be seelcted, may be null
 * @return boolean for future extension, currently always true
 */
public static boolean showCustomizer() {
    SdksCustomizer customizer
            = new SdksCustomizer();
    javax.swing.JButton close = new javax.swing.JButton(NbBundle.getMessage(SdksCustomizer.class, "CTL_Close"));
    close.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SdksCustomizer.class, "AD_Close"));
    DialogDescriptor descriptor = new DialogDescriptor(customizer, NbBundle.getMessage(SdksCustomizer.class,
            "TXT_PlatformsManager"), true, new Object[]{close}, close, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.nbandroid.netbeans.gradle.v2.sdk.ui.PlatformsCustomizer"), null); // NOI18N
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
    return true;
}
 
Example 14
Source Project: netbeans   Source File: ApisupportAntUIUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static @CheckForNull NbModuleProject runProjectWizard(
        final NewNbModuleWizardIterator iterator, final String titleBundleKey) {
    WizardDescriptor wd = new WizardDescriptor(iterator);
    wd.setTitleFormat(new MessageFormat("{0}")); // NOI18N
    wd.setTitle(NbBundle.getMessage(ApisupportAntUIUtils.class, titleBundleKey));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wd);
    dialog.setVisible(true);
    dialog.toFront();
    NbModuleProject project = null;
    boolean cancelled = wd.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        FileObject folder = iterator.getCreateProjectFolder();
        if (folder == null) {
            return null;
        }
        try {
            project = (NbModuleProject) ProjectManager.getDefault().findProject(folder);
            OpenProjects.getDefault().open(new Project[] { project }, false);
        } catch (IOException e) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
        }
    }
    return project;
}
 
Example 15
Source Project: netbeans   Source File: Selenium2Customizer.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("MSG_CONFIGURE=Configure Selenium Server")
public static boolean showCustomizer() {
    Selenium2Customizer panel = new Selenium2Customizer();
    DialogDescriptor descriptor = new DialogDescriptor(panel, Bundle.MSG_CONFIGURE());
    panel.setDescriptor(descriptor);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    dialog.setModal(true);
    dialog.setVisible(true);
    dialog.dispose();
    if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
        Selenium2ServerSupport.getPrefs().put(Selenium2ServerSupport.SELENIUM_SERVER_JAR, panel.tfSeleniumServerJar.getText());
        Selenium2ServerSupport.getPrefs().put(Selenium2ServerSupport.FIREFOX_PROFILE_TEMPLATE_DIR, panel.tfFirefoxProfileDir.getText());
        Selenium2ServerSupport.getPrefs().put(Selenium2ServerSupport.USER_EXTENSION_FILE, panel.tfUserExtensionFile.getText());
        Selenium2ServerSupport.getPrefs().putInt(Selenium2ServerSupport.PORT, Integer.parseInt(panel.spinnerPort.getValue().toString()));
        Selenium2ServerSupport.getPrefs().putBoolean(Selenium2ServerSupport.SINGLE_WINDOW, panel.cbSingleWindow.isSelected());
        return true;
    } else {
        return false;
    }
}
 
Example 16
Source Project: netbeans   Source File: MethodExceptionDialog.java    License: Apache License 2.0 6 votes vote down vote up
public void showDialog(JComponent invoker) {
    DialogDescriptor dlg = new DialogDescriptor(
            this,
            NbBundle.getMessage(this.getClass(), "CLIENT_EXCEPTION"), // NOI18N
            false,
            NotifyDescriptor.OK_CANCEL_OPTION,
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            null);
    dlg.setOptions(new Object[] { okButton });
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg);
    dialog.setPreferredSize(new Dimension(500,300));
    dialog.setLocationRelativeTo(invoker);
    dialog.setVisible(true);
}
 
Example 17
Source Project: lucene-solr   Source File: CreateIndexDialogFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JDialog create(Window owner, String title, int width, int height) {
  dialog = new JDialog(owner, title, Dialog.ModalityType.APPLICATION_MODAL);
  dialog.add(content());
  dialog.setSize(new Dimension(width, height));
  dialog.setLocationRelativeTo(owner);
  dialog.getContentPane().setBackground(prefs.getColorTheme().getBackgroundColor());
  return dialog;
}
 
Example 18
Source Project: marathonv5   Source File: WindowTitle.java    License: Apache License 2.0 5 votes vote down vote up
private String getTitle(Component component) {
    String title = null;
    if (component instanceof Dialog) {
        title = ((Dialog) component).getTitle();
    } else if (component instanceof Frame) {
        title = ((Frame) component).getTitle();
    }
    return title == null ? "<NoTitle>" : title;
}
 
Example 19
Source Project: JDKSourceCode1.8   Source File: JFileChooser.java    License: MIT License 5 votes vote down vote up
/**
 * Creates and returns a new <code>JDialog</code> wrapping
 * <code>this</code> centered on the <code>parent</code>
 * in the <code>parent</code>'s frame.
 * This method can be overriden to further manipulate the dialog,
 * to disable resizing, set the location, etc. Example:
 * <pre>
 *     class MyFileChooser extends JFileChooser {
 *         protected JDialog createDialog(Component parent) throws HeadlessException {
 *             JDialog dialog = super.createDialog(parent);
 *             dialog.setLocation(300, 200);
 *             dialog.setResizable(false);
 *             return dialog;
 *         }
 *     }
 * </pre>
 *
 * @param   parent  the parent component of the dialog;
 *                  can be <code>null</code>
 * @return a new <code>JDialog</code> containing this instance
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since 1.4
 */
protected JDialog createDialog(Component parent) throws HeadlessException {
    FileChooserUI ui = getUI();
    String title = ui.getDialogTitle(this);
    putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
                      title);

    JDialog dialog;
    Window window = JOptionPane.getWindowForComponent(parent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    dialog.setComponentOrientation(this.getComponentOrientation());

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations =
        UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations) {
            dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
        }
    }
    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    return dialog;
}
 
Example 20
Source Project: BART   Source File: ChartsPanel.java    License: MIT License 5 votes vote down vote up
private Dialog createDialog(JPanel inner, String title)   {
    final Dialog d = new ChartDialog(inner, title);
    d.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            dialogs.remove(d);
        }
        
    });
    return d;
}
 
Example 21
public ListEditor(Dialog parent) {
    this.parent = parent;
    list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setPrototypeCellValue("012345678901234567890123456789"); // about 30 characters wide
    list.addListSelectionListener(this);

    JPanel buttonColumn = makeButtonColumn();

    JScrollPane scroller = new JScrollPane(list);
    JPanel moveUpDownColumn = makeMoveUpDownColumn();


    setLayout(new GridBagLayout());
    GridBagConstraints gbConst = new GridBagConstraints();

    gbConst.gridx = 0;
    gbConst.weightx = 1.0;
    gbConst.weighty = 1.0;
    add(buttonColumn, gbConst);

    add(Box.createHorizontalStrut(5));

    gbConst.fill = GridBagConstraints.BOTH;
    gbConst.gridx = GridBagConstraints.RELATIVE;
    gbConst.weightx = 10.0;
    add(scroller, gbConst);

    add(Box.createHorizontalStrut(5));

    gbConst.fill = GridBagConstraints.NONE;
    gbConst.weightx = 1.0;
    add(moveUpDownColumn, gbConst);
}
 
Example 22
Source Project: opensim-gui   Source File: DialogUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void addCloseButton(Dialog dDialog, ActionListener actionListener) {
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createRigidArea(new Dimension(50, 50)));
    buttonPanel.add(Box.createVerticalStrut(50));
    buttonPanel.add(Box.createGlue());
    dDialog.add(buttonPanel, BorderLayout.SOUTH);
    JButton closeButton = new JButton("Close");
    buttonPanel.add(closeButton);
    closeButton.addActionListener(actionListener);
    dDialog.doLayout();
    dDialog.pack();
}
 
Example 23
Source Project: netbeans   Source File: BindingPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void trustButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trustButtonActionPerformed
    String profile = (String) profileCombo.getSelectedItem();
    TruststorePanel storePanel = new TruststorePanel(binding, project, jsr109, profile, false, getUserExpectedConfigVersion());
    DialogDescriptor dlgDesc = new DialogDescriptor(storePanel,
            NbBundle.getMessage(BindingPanel.class, "LBL_Truststore_Panel_Title")); //NOI18N
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true);
    if (dlgDesc.getValue() == DialogDescriptor.OK_OPTION) {
        storePanel.storeState();
    }
}
 
Example 24
Source Project: jdk8u60   Source File: ImageableAreaTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
Example 25
public synchronized void notifyChangeRequest(Component comp) {
    if (!(comp instanceof Frame || comp instanceof Dialog))
        return;

    // if busy with the current request, ignore this request.
    if (requestComponent != null)
        return;

    requestComponent = comp;
    notify();
}
 
Example 26
Source Project: netbeans   Source File: CreateSampleDBAction.java    License: Apache License 2.0 5 votes vote down vote up
public void performAction() {
    if (!Util.checkInstallLocation()) {
        return;
    }
    if (!Util.ensureSystemHome()) {
        return;
    }
    
    String derbySystemHome = DerbyOptions.getDefault().getSystemHome();
    CreateSampleDatabasePanel panel = new CreateSampleDatabasePanel(derbySystemHome);
    DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage(CreateSampleDBAction.class, "LBL_CreateSampleDatabaseTitle"), true, null);
    desc.createNotificationLineSupport();
    panel.setDialogDescriptor(desc);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(desc);
    panel.setIntroduction();
    String acsd = NbBundle.getMessage(CreateSampleDBAction.class, "ACSD_CreateDatabaseAction");
    dialog.getAccessibleContext().setAccessibleDescription(acsd);
    dialog.setVisible(true);
    dialog.dispose();
    
    if (!DialogDescriptor.OK_OPTION.equals(desc.getValue())) {
        return;
    }
    
    String databaseName = panel.getDatabaseName();
    
    try {
        DerbyDatabasesImpl.getDefault().createSampleDatabase(databaseName, true);
    } catch (Exception e) {
        LOG.log(Level.INFO, null, e);
        LOG.log(Level.INFO, "", e);
        NotifyDescriptor nd = new NotifyDescriptor.Message(
                "Failed to ceate sample database:\n"
                + e.getLocalizedMessage(),
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    }
}
 
Example 27
Source Project: pumpernickel   Source File: PreferencePanel.java    License: MIT License 5 votes vote down vote up
/** Show the component associated with a particular button. */
public void show(AbstractButton button) {
	if (selectedButton == button)
		return;

	selectedButton = button;

	String title = defaultTitle;
	if (selectedButton != homeButton) {
		title = selectedButton.getText();
	}
	Window w = SwingUtilities.getWindowAncestor(this);
	if (w instanceof Dialog) {
		((Dialog) w).setTitle(title);
	} else if (w instanceof Frame) {
		((Frame) w).setTitle(title);
	}

	if (navigationStack.get(navigationPtr) != button) {
		while (navigationStack.size() > navigationPtr + 1) {
			navigationStack.remove(navigationStack.size() - 1);
		}
		navigationStack.add(button);
		navigationPtr = navigationStack.size() - 1;
	}
	repack();
}
 
Example 28
Source Project: hottub   Source File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void clickOnTitle(final Window decoratedWindow, final Robot robot) {
    if (decoratedWindow instanceof Frame || decoratedWindow instanceof Dialog) {
        Point p = getTitlePoint(decoratedWindow);
        robot.mouseMove(p.x, p.y);
        robot.delay(50);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.delay(50);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    }
}
 
Example 29
Source Project: openjdk-jdk8u   Source File: NpeOnCloseTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
Example 30
Source Project: netbeans   Source File: SelectionPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Shows the edit panel.
 */
@org.netbeans.api.annotations.common.SuppressWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ",
        justification = "Comparing instances is OK here")
@NbBundle.Messages({
    "SelectionPanel.editDialog.title=Edit Library",
    "SelectionPanel.editDialog.update=Update",
    "SelectionPanel.editDialog.cancel=Cancel"
})
private void showEditPanel() {
    int selectedRow = librariesTable.getSelectedRow();
    Library.Version selectedVersion = libraries.get(selectedRow);
    Library library = libraryInfo.get(selectedVersion.getLibrary().getName());
    EditPanel editPanel = new EditPanel(library, selectedVersion);
    String update = Bundle.SelectionPanel_editDialog_update();
    String cancel = Bundle.SelectionPanel_editDialog_cancel();
    DialogDescriptor descriptor = new DialogDescriptor(
            editPanel,
            Bundle.SelectionPanel_editDialog_title(),
            true,
            new Object[] { update, cancel },
            update,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            null
    );
    Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    dialog.setVisible(true);
    if (descriptor.getValue() == update) {
        Library.Version version = editPanel.getSelection();
        if (version == null) {
            removeSelectedLibraries();
        } else {
            addLibrary(version);
        }
    }
}