Java Code Examples for javax.swing.JDialog#setContentPane()

The following examples show how to use javax.swing.JDialog#setContentPane() . 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 File: ATUJPLAG.java    From jplag with GNU General Public License v3.0 6 votes vote down vote up
private void showStartDialog() {
	dialog = new JDialog();

	JPanel panel = new JPanel();
	panel.setPreferredSize(new Dimension(300, 140));
	panel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.blue, 2));
	dialog.setContentPane(panel);

	JLabel label = new JLabel();
	label.setIcon(new ImageIcon(getClass().getResource("/atujplag/data/biglogo.gif"))); //$NON-NLS-1$
	panel.add(label);
	dialog.setUndecorated(true);
	dialog.getContentPane().setBackground(Color.WHITE);

	dialog.pack();
	dialog.setLocationRelativeTo(null);
	dialog.setVisible(true);
}
 
Example 2
Source File: WebBeansActionHelper.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void showObserversDialog( List<ExecutableElement> methods , 
        MetadataModel<WebBeansModel> metaModel , WebBeansModel model,
        Object[] subject, ObserversModel uiModel ,
        String name ) 
{
    subject[2] = InspectActionId.OBSERVERS_CONTEXT;
    StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
            InjectablesModel.class, WAIT_NODE));
    JDialog dialog = ResizablePopup.getDialog();
    String title = NbBundle.getMessage(WebBeansActionHelper.class,
            "TITLE_Observers" , name );//NOI18N
    dialog.setTitle( title );
    dialog.setContentPane( new ObserversPanel(subject, metaModel, 
            model ,uiModel ));
    dialog.setVisible( true );
    
}
 
Example 3
Source File: LoadingWindow.java    From jmg with GNU General Public License v2.0 6 votes vote down vote up
public static void showLoadingWindow()
{
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e) {
	} 
	JOptionPane pane = new JOptionPane("Загрузка. Пожалуйста, подождите...", JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
	
	LOADING_PANE = new JDialog();
	LOADING_PANE.setModal(false);

	LOADING_PANE.setContentPane(pane);

	LOADING_PANE.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

	LOADING_PANE.setLocation(100, 200);
	LOADING_PANE.pack();
	LOADING_PANE.setVisible(true);
}
 
Example 4
Source File: DownloadBulkWizard.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public DownloadBulkWizard(String entityType, String destinationPath) {
	String message = I18NSupport.getString("download");
	dialog = new JDialog(Globals.getMainFrame(), message, true);

	PublishLoginWizardPanel loginPanel = new PublishLoginWizardPanel(null) {			
		public WizardPanel getNextPanel() {
			return new DownloadListWizardPanel();
		}			
	};
	
	Wizard wizard = new Wizard(loginPanel);
	wizard.getContext().setAttribute(PublishWizard.MAIN_FRAME, dialog);
	wizard.getContext().setAttribute(DESTINATION, destinationPath);
	wizard.getContext().setAttribute(WizardConstants.ENTITY, entityType);
	wizard.addWizardListener(this);
	
	dialog.setContentPane(wizard);
	dialog.setSize(400, 340);
	dialog.setLocationRelativeTo(null);
	dialog.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			super.windowClosing(e);
		}
	});
	dialog.setVisible(true);
}
 
Example 5
Source File: WebBeansActionHelper.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void showInjectablesDialog( MetadataModel<WebBeansModel> metamodel,
        WebBeansModel model, Object[] subject, 
        InjectablesModel uiModel , String name , 
        org.netbeans.modules.web.beans.api.model.Result result ) 
{
    subject[2] = InspectActionId.INJECTABLES_CONTEXT;
    StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
            InjectablesModel.class, WAIT_NODE));           // NOI18N
    JDialog dialog = ResizablePopup.getDialog();
    String title = NbBundle.getMessage(WebBeansActionHelper.class,
            "TITLE_Injectables" , name );//NOI18N
    dialog.setTitle( title );
    dialog.setContentPane( new BindingsPanel(subject, metamodel, model,
            uiModel, result ));
    dialog.setVisible( true );
}
 
Example 6
Source File: SwingWorkerWithProgressIndicatorDialog.java    From PyramidShader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * Must be called in the Event Dispatching Thread.
 *
 * @param owner owner of dialog
 * @param dialogTitle title for new dialog
 * @param message message displayed in dialog
 * @param blockOwner
 */
public SwingWorkerWithProgressIndicatorDialog(Frame owner,
        ProgressPanel progressPanel,
        String dialogTitle) {
    super(progressPanel);

    assert (SwingUtilities.isEventDispatchThread());

    // prepare the dialog
    dialog = new JDialog(owner, dialogTitle);
    dialog.setModal(true);
    dialog.setResizable(false);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    progressPanel.setMessage(getProgressMessage());
    progressPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    dialog.setContentPane(progressPanel);
    dialog.pack();
    dialog.setLocationRelativeTo(owner);
}
 
Example 7
Source File: WebBeansActionHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void showEventsDialog( MetadataModel<WebBeansModel> metaModel , 
        WebBeansModel model,Object[] subject, 
        EventsModel uiModel , String name ) 
{
    subject[2] = InspectActionId.METHOD_CONTEXT;
    StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
            InjectablesModel.class, WAIT_NODE));
    JDialog dialog = ResizablePopup.getDialog();
    String title = NbBundle.getMessage(WebBeansActionHelper.class,
            "TITLE_Events" , name );//NOI18N
    dialog.setTitle( title );
    dialog.setContentPane( new EventsPanel(subject, metaModel, 
            model ,uiModel ));
    dialog.setVisible( true );
}
 
Example 8
Source File: Utilities.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Affiche un texte scrollable non éditable dans une popup.
 * @param component Parent
 * @param title Titre de la popup
 * @param text Texte
 */
public static void showTextInPopup(Component component, String title, String text) {
	final JTextArea textArea = new JTextArea();
	textArea.setText(text);
	textArea.setEditable(false);
	textArea.setCaretPosition(0);
	// background nécessaire avec la plupart des look and feels dont Nimbus,
	// sinon il reste blanc malgré editable false
	textArea.setBackground(Color.decode("#E6E6E6"));
	final JScrollPane scrollPane = new JScrollPane(textArea);

	final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
	final MButton clipBoardButton = new MButton(
			I18NAdapter.getString("Copier_dans_presse-papiers"));
	clipBoardButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			textArea.selectAll();
			textArea.copy();
			textArea.setCaretPosition(0);
		}
	});
	buttonPanel.setOpaque(false);
	buttonPanel.add(clipBoardButton);

	final Window window = SwingUtilities.getWindowAncestor(component);
	final JDialog dialog = new JDialog((JFrame) window, title, true);
	final JPanel contentPane = new JPanel(new BorderLayout());
	contentPane.add(scrollPane, BorderLayout.CENTER);
	contentPane.add(buttonPanel, BorderLayout.SOUTH);
	dialog.setContentPane(contentPane);
	dialog.pack();
	dialog.setLocationRelativeTo(window);
	dialog.setVisible(true);
}
 
Example 9
Source File: CompareChangesDialog.java    From BART with MIT License 5 votes vote down vote up
public void showResults(String results) {
    JDialog dialog = new JDialog(this, true);
    dialog.setSize(500, 300);
    dialog.setLocationRelativeTo(this);
    JTextArea textArea = new JTextArea(results);
    textArea.setEditable(false);
    textArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    dialog.setContentPane(new JScrollPane(textArea));
    dialog.setVisible(true);
}
 
Example 10
Source File: DialogUtils.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Centers the dialog over the given parent component. Also, creates a
 * semi-transparent panel behind the dialog to mask the parent content.
 * The title of the dialog is displayed in a custom fashion over the dialog
 * panel, and a rectangular shadow is placed behind the dialog.
 */
public static void createDialogBackPanel(JDialog dialog, Component parent) {
	dialog.setBackground(new Color(255, 255, 255, 64));
	
	DialogBackPanel newContentPane = new DialogBackPanel(dialog.getContentPane(), dialog.getTitle());
	dialog.setContentPane(newContentPane);
	dialog.setSize(parent.getSize());
	dialog.setLocation(parent.getLocationOnScreen());
}
 
Example 11
Source File: DeprecationWarning.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Restores the previous content pane of the dialog
 *
 * @param dialog
 * 		the same dialog that was used for {@link #addToDialog(JDialog)}
 */
public void removeFromDialog(JDialog dialog) {
	Container contentPane = originalContentPane;
	if (equals(dialog.getContentPane()) && contentPane != null) {
		dialog.setContentPane(contentPane);
		originalContentPane = null;
	}
}
 
Example 12
Source File: OSPInspector.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Shows the inspector.
 *
 * @return Object the object being inspected.
 */
public Object show() {
  xml.saveObject(obj); // needed in case object has been recently modified
  JDialog dialog = new JDialog((java.awt.Frame) null, true);
  dialog.setContentPane(new XMLTreePanel(xml));
  dialog.setSize(new Dimension(600, 300));
  dialog.setTitle(shortObjectName+" "+ControlsRes.getString("OSPInspector.Title")); //$NON-NLS-1$ //$NON-NLS-2$
  dialog.setVisible(true);
  obj = xml.loadObject(null);
  return obj;
}
 
Example 13
Source File: AboutAction.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    JDialog dialog = new JDialog(WindowManager.getDefault().getMainWindow(), Bundle.CTL_AboutAction_Title(), true);
    dialog.setContentPane(new AboutPanel());
    dialog.pack();
    dialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}
 
Example 14
Source File: DiagnosticsForSystem.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
public static void aboutSystem(Frame owner) {
    JDialog dialog = new JDialog(owner,"System Properties");  //$NON-NLS-1$
    DiagnosticsForSystem viewer = new DiagnosticsForSystem();
    dialog.setContentPane(viewer);
    dialog.setSize(500, 300);
    dialog.setVisible(true);	  
}
 
Example 15
Source File: EjsControlFrame.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
public void inspectXML() {
  // display a TreePanel in a modal dialog
  XMLControl xml = new XMLControlElement(getOSPApp());
  XMLTreePanel treePanel = new XMLTreePanel(xml);
  JDialog dialog = new JDialog((java.awt.Frame) null, true);
  dialog.setContentPane(treePanel);
  dialog.setSize(new Dimension(600, 300));
  dialog.setVisible(true);
}
 
Example 16
Source File: ScoreActions.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Prompts the user for interactive confirmation or modification of
 * score/page parameters
 *
 * @param sheet the current sheet, or null
 * @return true if parameters are applied, false otherwise
 */
private static boolean applyUserSettings (final Sheet sheet)
{
    try {
        final WrappedBoolean apply = new WrappedBoolean(false);
        final ScoreParameters scoreParams = new ScoreParameters(sheet);
        final JOptionPane optionPane = new JOptionPane(
                scoreParams.getComponent(),
                JOptionPane.QUESTION_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION);
        final String frameTitle = (sheet != null)
                ? (sheet.getScore()
                .getRadix()
                   + " parameters")
                : "General parameters";
        final JDialog dialog = new JDialog(
                Main.getGui().getFrame(),
                frameTitle,
                true); // Modal flag
        dialog.setContentPane(optionPane);
        dialog.setName("scoreParams");

        optionPane.addPropertyChangeListener(
                new PropertyChangeListener()
        {
            @Override
            public void propertyChange (PropertyChangeEvent e)
            {
                String prop = e.getPropertyName();

                if (dialog.isVisible()
                    && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    Object obj = optionPane.getValue();
                    int value = ((Integer) obj).intValue();
                    apply.set(value == JOptionPane.OK_OPTION);

                    // Exit only if user gives up or enters correct data
                    if (!apply.isSet()
                        || scoreParams.commit(sheet)) {
                        dialog.setVisible(false);
                        dialog.dispose();
                    } else {
                        // Incorrect data, so don't exit yet
                        try {
                            // TODO: Is there a more civilized way?
                            optionPane.setValue(
                                    JOptionPane.UNINITIALIZED_VALUE);
                        } catch (Exception ignored) {
                        }
                    }
                }
            }
        });

        dialog.pack();
        MainGui.getInstance()
                .show(dialog);

        return apply.value;
    } catch (Exception ex) {
        logger.warn("Error in ScoreParameters", ex);

        return false;
    }
}
 
Example 17
Source File: AbstractModalDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public final int show() {
    JDialog dialog = getJDialog();
    if (!dialog.isShowing()) {
        this.componentsAllwaysEnabled = new ArrayList<JComponent>();

        ActionListener cancelActionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                close();
            }
        };
        registerEscapeKey(cancelActionListener);

        ComponentsEnabled componentsEnabled = new ComponentsEnabled() {
            @Override
            public void setComponentsEnabled(boolean enabled) {
                setEnabledComponentsWhileLoading(enabled);
            }
        };
        this.loadingIndicatorPanel = new LoadingIndicatorPanel(componentsEnabled);
        dialog.getLayeredPane().add(this.loadingIndicatorPanel, JLayeredPane.MODAL_LAYER);

        int gapBetweenColumns = getDefaultGapBetweenColumns();
        int gapBetweenRows = getDefaultGapBetweenRows();

        JPanel contentPanel = buildContentPanel(gapBetweenColumns, gapBetweenRows);
        JPanel buttonsPanel = buildButtonsPanel(cancelActionListener);

        JPanel dialogContentPanel = new JPanel(new BorderLayout(0, getDefaultGapBetweenContentAndButtonPanels()));
        dialogContentPanel.add(contentPanel, BorderLayout.CENTER);
        dialogContentPanel.add(buttonsPanel, BorderLayout.SOUTH);
        Border dialogBorder = buildDialogBorder(getDefaultContentPanelMargins());
        dialogContentPanel.setBorder(dialogBorder);

        dialog.setContentPane(dialogContentPanel);

        dialog.setResizable(true);
        dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        dialog.setUndecorated(false);
        dialog.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent aEvent) {
                close();
            }
        });
        dialog.pack();
        dialog.setLocationRelativeTo(dialog.getParent());

        onAboutToShow();

        dialog.setVisible(true);
    }
    return 0;
}
 
Example 18
Source File: VizController.java    From ontopia with Apache License 2.0 4 votes vote down vote up
private TopicMapIF importTopicMap(TopicMapReaderIF reader, String name) {
  final JOptionPane pane = new JOptionPane(new Object[] { Messages
      .getString("Viz.LoadingTopicMap") + name },
      JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
      new String[] {}, null);

  Frame frame = JOptionPane.getFrameForComponent(vpanel);
  final JDialog dialog = new JDialog(frame, Messages
      .getString("Viz.Information"), true);

  dialog.setContentPane(pane);
  dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
  dialog.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent we) {
      JOptionPane
          .showMessageDialog(pane,
              Messages.getString("Viz.CannotCancelOperation"), 
              Messages.getString("Viz.Information"),
              JOptionPane.INFORMATION_MESSAGE);
    }
  });

  dialog.pack();
  dialog.setLocationRelativeTo(frame);

  TopicMapIF tm;
  final TopicMapReaderIF r = reader;

  final SwingWorker worker = new SwingWorker() {
    @Override
    public Object construct() {
      TopicMapIF result = null;
      try {
        result = r.read();
      } catch (IOException e) {
        dialog.setVisible(false);
        ErrorDialog.showError(vpanel, e.getMessage());
      }
      return result;
    }

    @Override
    public void finished() {
      dialog.setVisible(false);
    }
  };

  worker.start();
  dialog.setVisible(true);
  tm = (TopicMapIF) worker.getValue();
  return tm;
}
 
Example 19
Source File: UserActionPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent event) {
  final JDialog userChoiceDialog = new JDialog(parent, "Actions and Operations", true);

  final JPanel userChoicePanel = new JPanel();
  userChoicePanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
  userChoicePanel.setLayout(new GridBagLayout());

  int row = 0;
  final JScrollPane choiceScroll =
      new JScrollPane(getUserActionButtonPanel(userChoiceDialog));
  choiceScroll.setBorder(BorderFactory.createEtchedBorder());
  userChoicePanel.add(
      choiceScroll,
      new GridBagConstraints(
          0,
          row++,
          2,
          1,
          1,
          1,
          GridBagConstraints.CENTER,
          GridBagConstraints.BOTH,
          new Insets(0, 0, 0, 0),
          0,
          0));

  final JButton noActionButton =
      new JButton(SwingAction.of("No Actions", e -> userChoiceDialog.setVisible(false)));
  SwingUtilities.invokeLater(noActionButton::requestFocusInWindow);
  userChoicePanel.add(
      noActionButton,
      new GridBagConstraints(
          0,
          row,
          2,
          1,
          0.0,
          0.0,
          GridBagConstraints.EAST,
          GridBagConstraints.NONE,
          new Insets(12, 0, 0, 0),
          0,
          0));

  userChoiceDialog.setContentPane(userChoicePanel);
  userChoiceDialog.pack();
  userChoiceDialog.setLocationRelativeTo(parent);
  userChoiceDialog.setVisible(true);
  userChoiceDialog.dispose();
}
 
Example 20
Source File: LicenseCompanion.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void doInstall ()
        throws Exception
{
    // When running without UI, we assume license is accepted
    if (!Installer.hasUI()) {
        return;
    }

    // User choice (must be an output, yet final)
    final boolean[] isOk = new boolean[1];

    final String yes = "Yes";
    final String no = "No";
    final String browse = "View License";
    final JOptionPane optionPane = new JOptionPane(
            "Do you agree to license " + LICENSE_NAME + "?",
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_CANCEL_OPTION,
            null,
            new Object[]{yes, no, browse},
            yes);
    final String frameTitle = "End User License Agreement";
    final JDialog dialog = new JDialog(
            Installer.getFrame(),
            frameTitle,
            true);
    dialog.setContentPane(optionPane);

    // Prevent dialog closing
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    optionPane.addPropertyChangeListener(
            new PropertyChangeListener()
    {
        @Override
        public void propertyChange (PropertyChangeEvent e)
        {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                Object option = optionPane.getValue();
                logger.debug("option: {}", option);

                if (option == yes) {
                    isOk[0] = true;
                    dialog.setVisible(false);
                    dialog.dispose();
                } else if (option == no) {
                    isOk[0] = false;
                    dialog.setVisible(false);
                    dialog.dispose();
                } else if (option == browse) {
                    logger.info(
                            "Launching browser on {}",
                            LICENSE_URL);
                    showLicense();
                    optionPane.setValue(
                            JOptionPane.UNINITIALIZED_VALUE);
                } else {
                }
            }
        }
    });

    dialog.pack();
    dialog.setLocationRelativeTo(Installer.getFrame());
    dialog.setVisible(true);

    logger.debug("OK: {}", isOk[0]);

    if (!isOk[0]) {
        throw new LicenseDeclinedException();
    }
}