java.awt.Dialog.ModalityType Java Examples

The following examples show how to use java.awt.Dialog.ModalityType. 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: EncryptBackMultipleView.java    From pgptool with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("encrypBackMany.action"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	{
		// DIRTY-HACK: YES, FOLLOWING 2 LINES ARE REPEATED BY INTENTION,
		// OTHERWISE JXlABEL IS NOT
		// RETURNING CORRECT PREFERRED SIZE AND WHOLE LAYOUT IS SCREWED UP
		// THE ONLY WAY TO FORCE IT IS TO CENTER WINDOW. SO ONCE WE DID
		// FIRST TIME NOW WE CAN PACK AND CENTER AGAIN
		ret.pack();
		UiUtils.centerWindow(ret, owner);
	}
	return ret;
}
 
Example #2
Source File: ExpertSetup.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Displays dialog for entering notes in Markdown.
 */
protected void editNotes() {
	MarkdownDialog dialog;

	if (getParentDialog() != null)
		dialog = new MarkdownDialog(getParentDialog(), ModalityType.DOCUMENT_MODAL);
	else
		dialog = new MarkdownDialog(getParentFrame(), true);
	dialog.setTitle("Edit notes");
	dialog.setMarkdown(m_Notes);
	dialog.setSize(600, 400);
	dialog.setLocationRelativeTo(null);
	dialog.setVisible(true);
	if (dialog.getOption() != MarkdownDialog.APPROVE_OPTION)
		return;
	m_Notes = dialog.getMarkdown();
	setModified(true);
	updateButtons();
}
 
Example #3
Source File: ModelController.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
public Window show(Model model) {
   Window window = windows.computeIfAbsent(model.getAddress(), (address) -> {
      ModelTableView view = new ModelTableView();
      view.bind(new DefaultSelectionModel<Model>(model));
      
      JDialog dialog = new JDialog(null, model.getAddress(), ModalityType.MODELESS);
      dialog.add(new JScrollPane(view.getComponent()));
      dialog.setSize(600, 400);
      dialog.addWindowListener(new WindowAdapter() {
         /* (non-Javadoc)
          * @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
          */
         @Override
         public void windowClosed(WindowEvent e) {
            view.dispose();
         }
      });
      
      return dialog;
   });
   window.setVisible(true);
   return window;
}
 
Example #4
Source File: BasicSetup.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Displays dialog for entering notes in Markdown.
 */
protected void editNotes() {
	MarkdownDialog dialog;

	if (getParentDialog() != null)
		dialog = new MarkdownDialog(getParentDialog(), ModalityType.DOCUMENT_MODAL);
	else
		dialog = new MarkdownDialog(getParentFrame(), true);
	dialog.setTitle("Edit notes");
	dialog.setMarkdown(m_Notes);
	dialog.setSize(600, 400);
	dialog.setLocationRelativeTo(null);
	dialog.setVisible(true);
	if (dialog.getOption() != MarkdownDialog.APPROVE_OPTION)
		return;
	m_Notes = dialog.getMarkdown();
	setModified(true);
	updateButtons();
}
 
Example #5
Source File: WhoIsPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Show a dialog with whois data for the given point
 * @param parent
 * @param whois
 * @param point
 */
public static void showWhoIsDialog(final JComponent parent, final ServiceFactory services, final GeoPoint point) {
	final WhoIsPanel panel = new WhoIsPanel(services);
	final JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(parent), "Who is " + point.getIp(), ModalityType.APPLICATION_MODAL) {

		private static final long serialVersionUID = 1258611715478157956L;

		@Override
		public void dispose() {
			panel.dispose();
			super.dispose();
		}

	};
	dialog.getContentPane().add(panel, BorderLayout.CENTER);
	final JPanel bottom = new JPanel();
	final JButton close = new JButton(Resources.getLabel("close.button"));
	close.addActionListener(e -> dialog.dispose());
	bottom.add(close);
	dialog.getContentPane().add(bottom, BorderLayout.SOUTH);
	services.getWhois().whoIs(point.getIp());
	SwingUtilities4.setUp(dialog);
	dialog.setVisible(true);

}
 
Example #6
Source File: MacroEditor.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void showMacroEditorDialog(final ProcessContext context) {
	ButtonDialog dialog = new ButtonDialog(ApplicationFrame.getApplicationFrame(), "define_macros",
			ModalityType.APPLICATION_MODAL, new Object[] {}) {

		private static final long serialVersionUID = 2874661432345426452L;

		{
			MacroEditor editor = new MacroEditor(false);
			editor.setBorder(createBorder());
			JButton addMacroButton = new JButton(editor.ADD_MACRO_ACTION);
			JButton removeMacroButton = new JButton(editor.REMOVE_MACRO_ACTION);
			layoutDefault(editor, NORMAL, addMacroButton, removeMacroButton, makeOkButton());
		}

		@Override
		protected void ok() {
			super.ok();
		}
	};
	dialog.setVisible(true);
}
 
Example #7
Source File: SwingUtils.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
static public JDialog addModelessWindow(Frame mainWindow, Component jpanel, String title) {
	JDialog dialog = new JDialog(mainWindow, title, true);
	dialog.getContentPane().setLayout(new BorderLayout());
	dialog.getContentPane().add(jpanel, BorderLayout.CENTER);
	dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	dialog.pack();
	dialog.setLocationRelativeTo(mainWindow);
	dialog.setModalityType(ModalityType.MODELESS);
	dialog.setSize(jpanel.getPreferredSize());
	dialog.setVisible(true);
	return dialog;
}
 
Example #8
Source File: DialogViewBaseCustom.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void showDialog(Window optionalParent) {
	super.showDialog(optionalParent);
	if (dialog.getModalityType() == ModalityType.MODELESS) {
		UiUtils.makeSureWindowBroughtToFront(dialog);
	}
}
 
Example #9
Source File: EncryptOneView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.MODELESS);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(50), UiUtils.getFontRelativeSize(40)));
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.encrypt"));
	ret.add(pnl, BorderLayout.CENTER);
	initWindowGeometryPersister(ret, "encrOne");
	return ret;
}
 
Example #10
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/** @return Whether or not the application is currently in a modal state. */
public static boolean inModalState() {
    for (Window window : Window.getWindows()) {
        if (window instanceof Dialog) {
            Dialog dialog = (Dialog) window;
            if (dialog.isShowing()) {
                ModalityType type = dialog.getModalityType();
                if (type == ModalityType.APPLICATION_MODAL || type == ModalityType.TOOLKIT_MODAL) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #11
Source File: DataImportWizardBuilder.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Builds and layouts the configured {@link ImportWizard} dialog.
 *
 * @param owner
 * 		the dialog owner
 * @return the new {@link ImportWizard} instance
 */
public ImportWizard build(Window owner) {
	if (owner == null) {
		owner = ApplicationFrame.getApplicationFrame();
	}
	DataImportWizard wizard = new DataImportWizard(owner, ModalityType.DOCUMENT_MODAL, null);

	// add common steps
	TypeSelectionStep typeSelectionStep = new TypeSelectionStep(wizard);
	wizard.addStep(typeSelectionStep);
	wizard.addStep(new LocationSelectionStep(wizard, factoryI18NKey));
	if (storeData) {
		final StoreToRepositoryStep storeToRepositoryStep = new StoreToRepositoryStep(wizard);
		storeToRepositoryStep.setCallback(callback);
		wizard.addStep(storeToRepositoryStep);
	}
	wizard.addStep(new ConfigureDataStep(wizard, reader, storeData));

	// check whether a local file data source was specified
	if (localFileDataSourceFactory != null) {
		setDataSource(wizard, localFileDataSourceFactory,
				localFileDataSourceFactory.createNew(wizard, filePath, fileDataSourceFactory));
	}

	// Start with type selection
	String startingStep = typeSelectionStep.getI18NKey();

	// unless another starting step ID is specified
	if (startingStepID != null) {
		startingStep = startingStepID;
	}

	wizard.layoutDefault(ButtonDialog.HUGE, startingStep);
	return wizard;
}
 
Example #12
Source File: DepLoader.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public JDialog makeDialog() {
    if (container != null)
        return container;

    setMessageType(JOptionPane.INFORMATION_MESSAGE);
    setMessage(makeProgressPanel());
    setOptions(new Object[]{"Stop"});
    addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
                requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
            }
        }
    });
    container = new JDialog(null, "Hello", ModalityType.MODELESS);
    container.setResizable(false);
    container.setLocationRelativeTo(null);
    container.add(this);
    this.updateUI();
    container.pack();
    container.setMinimumSize(container.getPreferredSize());
    container.setVisible(true);
    container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    container.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
        }
    });
    return container;
}
 
Example #13
Source File: AdditionalPermissionsListener.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Checks if the parameter with the key was newly activated. Checks if it is allowed to be activated and shows a
 * warning dialog with the dialogKey. Otherwise it shows a dialog with the failedKey.
 *
 * @param key
 * 		the parameter service key to check
 * @param isAllowed
 * 		the license check
 * @param dialogKey
 * 		the key for the warning dialog
 * @param failedKey
 * 		the key for the failure dialog
 */
private void checkPermissions(String key, BooleanSupplier isAllowed, String dialogKey, String failedKey) {
	boolean permissionsActiveNow = Boolean.parseBoolean(ParameterService.getParameterValue(key));

	if (!wasActiveBefore(key) && permissionsActiveNow) {
		if (ProductConstraintManager.INSTANCE.isInitialized() && isAllowed.getAsBoolean()) {
			ButtonDialog dialog = new ButtonDialogBuilder(dialogKey)
					.setOwner(ApplicationFrame.getApplicationFrame())
					.setButtons(DefaultButtons.OK_BUTTON, DefaultButtons.CANCEL_BUTTON)
					.setModalityType(ModalityType.APPLICATION_MODAL).setContent(new JPanel(),
							ButtonDialog.DEFAULT_SIZE)
					.build();
			dialog.getRootPane().getDefaultButton().setText("Grant");
			dialog.getRootPane().getDefaultButton().setMnemonic('G');
			dialog.setVisible(true);
			if (!dialog.wasConfirmed()) {
				ParameterService.setParameterValue(key, String.valueOf(false));
				ParameterService.saveParameters();
			}
		} else {
			ParameterService.setParameterValue(key, String.valueOf(false));
			ParameterService.saveParameters();

			ButtonDialog smallLicenseDialog = new ButtonDialogBuilder(failedKey)
					.setOwner(ApplicationFrame.getApplicationFrame()).setButtons(DefaultButtons.OK_BUTTON)
					.setModalityType(ModalityType.APPLICATION_MODAL).setContent(new JPanel(), ButtonDialog.MESSAGE)
					.build();
			smallLicenseDialog.setVisible(true);
		}
	}
}
 
Example #14
Source File: BetaFeaturesListener.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void windowClosed(WindowEvent e) {
	boolean betaActiveNow = Boolean
			.parseBoolean(ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_UPDATE_BETA_FEATURES));
	if (!betaActiveBefore && betaActiveNow) {
		JTextArea textArea = new JTextArea();
		textArea.setColumns(60);
		textArea.setRows(15);
		textArea.setLineWrap(true);
		textArea.setWrapStyleWord(true);
		textArea.setEditable(false);
		textArea.setText(loadBetaEULA());
		textArea.setBorder(null);
		textArea.setCaretPosition(0);

		JScrollPane scrollPane = new ExtendedJScrollPane(textArea);
		scrollPane.setBorder(BorderFactory.createLineBorder(Colors.TEXTFIELD_BORDER));

		ButtonDialog dialog = new ButtonDialogBuilder("beta_features_eula")
				.setOwner(ApplicationFrame.getApplicationFrame())
				.setButtons(DefaultButtons.OK_BUTTON, DefaultButtons.CANCEL_BUTTON)
				.setModalityType(ModalityType.APPLICATION_MODAL).setContent(scrollPane, ButtonDialog.DEFAULT_SIZE)
				.build();
		dialog.setVisible(true);
		if (!dialog.wasConfirmed()) {
			ParameterService.setParameterValue(RapidMiner.PROPERTY_RAPIDMINER_UPDATE_BETA_FEATURES,
					String.valueOf(false));
			ParameterService.saveParameters();
			ActionStatisticsCollector.INSTANCE.log(ActionStatisticsCollector.TYPE_BETA_FEATURES,
					ActionStatisticsCollector.VALUE_BETA_FEATURES_ACTIVATION, "cancelled");
		}
	}
}
 
Example #15
Source File: DecryptTextView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.MODELESS);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(80), UiUtils.getFontRelativeSize(40)));
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.decryptText"));
	ret.add(pnl, BorderLayout.CENTER);
	initWindowGeometryPersister(ret, "decrText");
	return ret;
}
 
Example #16
Source File: AnimPlay.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Save the selected file's audio as Wave.
 * @param what the file to use as input
 * @param target the target output filename
 * @param modal show the dialog as modal?
 * @param parent the parent frame
 * @return the worker
 */
static SwingWorker<Void, Void> saveAsWavWorker(final File what, final File target, boolean modal, JFrame parent) {
	final ProgressFrame pf = new ProgressFrame("Save as WAV: " + target, parent);
	SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
		@Override
		protected Void doInBackground() throws Exception {
			transcodeToWav(what.getAbsolutePath(), target.getAbsolutePath(), new ProgressCallback() {
				@Override
				public void progress(final int value, final int max) {
					SwingUtilities.invokeLater(new Runnable() {
						@Override
						public void run() {
							pf.setMax(max);
							pf.setCurrent(value, "Progress: " + value + " / " + max + " frames");
						}
					});
				}
				@Override
				public boolean cancel() {
					return pf.isCancelled();
				}
			});
			return null;
		}
		@Override
		protected void done() {
			// delay window close a bit further
			SwingUtilities.invokeLater(new Runnable() {
				@Override
				public void run() {
					pf.dispose();
				}
			});
		}
	};
	worker.execute();
	pf.setModalityType(modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
	pf.setVisible(true);
	return worker;
}
 
Example #17
Source File: AnimPlay.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Worker for save as PNG.
 * @param what the file to convert
 * @param target the target filename
 * @param modal show the progress as a modal dialog?
 * @param parent the parent frame
 * @return the worker
 */
static SwingWorker<Void, Void> saveAsPNGWorker(final File what, final File target, boolean modal, JFrame parent) {
	final ProgressFrame pf = new ProgressFrame("Save as PNG: " + target, parent);
	SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
		@Override
		protected Void doInBackground() throws Exception {
			transcodeToPng(what.getAbsolutePath(), target.getAbsolutePath(), new ProgressCallback() {
				@Override
				public void progress(final int value, final int max) {
					SwingUtilities.invokeLater(new Runnable() {
						@Override
						public void run() {
							pf.setMax(max);
							pf.setCurrent(value, "Progress: " + value + " / " + max + " frames");
						}
					});
				}
				@Override
				public boolean cancel() {
					return pf.isCancelled();
				}
			});
			return null;
		}
		@Override
		protected void done() {
			// delay window close a bit further
			SwingUtilities.invokeLater(new Runnable() {
				@Override
				public void run() {
					pf.dispose();
				}
			});
		}
	};
	worker.execute();
	pf.setModalityType(modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
	pf.setVisible(true);
	return worker;
}
 
Example #18
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 5 votes vote down vote up
private void readmeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readmeMenuItemActionPerformed
    try {
        JTextArea textArea = new JTextArea();
        Font font = textArea.getFont();
        textArea.setFont(new Font("Monospaced", font.getStyle(), font.getSize()));
        textArea.setEditable(false);

        String text = "";
        BufferedReader r = new BufferedReader(new FileReader(
                myDirectory + File.separator + "../README.md"));
        String line;
        while ((line = r.readLine()) != null) {
            text += line + '\n';
        }

        textArea.setText(text);
        textArea.setCaretPosition(0);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setColumns(80);

        // stuff it in a scrollpane with a controlled size.
        JScrollPane scrollPane = new JScrollPane(textArea);
        Dimension dim = textArea.getPreferredSize();
        dim.height = dim.width*50/80;
        scrollPane.setPreferredSize(dim);

        // pass the scrollpane to the joptionpane.
        JDialog dialog = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE).
                createDialog(this, "README");
        dialog.setResizable(true);
        dialog.setModalityType(ModalityType.MODELESS);
        dialog.setVisible(true);
    } catch (Exception ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #19
Source File: KeysListView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setMinimumSize(new Dimension(spacing(50), spacing(25)));
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.keysList"));
	ret.add(panelRoot, BorderLayout.CENTER);
	ret.setJMenuBar(menuBar);
	initWindowGeometryPersister(ret, "keysList");
	return ret;
}
 
Example #20
Source File: GetKeyPasswordDialogView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.DOCUMENT_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.providePasswordForAKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
Example #21
Source File: AboutView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.aboutApp"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	return ret;
}
 
Example #22
Source File: CheckForUpdatesView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(text("action.checkForUpdates"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
Example #23
Source File: DecryptOneDialogView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.MODELESS);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.decrypt"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
Example #24
Source File: EncryptTextView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.MODELESS);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(80), UiUtils.getFontRelativeSize(40)));
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.encryptText"));
	ret.add(pnl, BorderLayout.CENTER);
	initWindowGeometryPersister(ret, "encrText");
	return ret;
}
 
Example #25
Source File: KeyImporterView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.importKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.setMinimumSize(new Dimension(spacing(60), spacing(30)));

	initWindowGeometryPersister(ret, "keyImprt");

	return ret;
}
 
Example #26
Source File: CreateKeyView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.createPgpKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
Example #27
Source File: MainFrame.java    From procamtracker with GNU General Public License v2.0 5 votes vote down vote up
private void readmeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readmeMenuItemActionPerformed
    try {
        JTextArea textArea = new JTextArea();
        Font font = textArea.getFont();
        textArea.setFont(new Font("Monospaced", font.getStyle(), font.getSize()));
        textArea.setEditable(false);

        String text = "";
        BufferedReader r = new BufferedReader(new FileReader(
                myDirectory + File.separator + "../README.md"));
        String line;
        while ((line = r.readLine()) != null) {
            text += line + '\n';
        }

        textArea.setText(text);
        textArea.setCaretPosition(0);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setColumns(80);

        // stuff it in a scrollpane with a controlled size.
        JScrollPane scrollPane = new JScrollPane(textArea);
        Dimension dim = textArea.getPreferredSize();
        dim.height = dim.width*50/80;
        scrollPane.setPreferredSize(dim);

        // pass the scrollpane to the joptionpane.
        JDialog dialog = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE).
                createDialog(this, "README");
        dialog.setResizable(true);
        dialog.setModalityType(ModalityType.MODELESS);
        dialog.setVisible(true);
    } catch (Exception ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #28
Source File: DepLoader.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
public JDialog makeDialog() {
    if (container != null)
        return container;

    setMessageType(JOptionPane.INFORMATION_MESSAGE);
    setMessage(makeProgressPanel());
    setOptions(new Object[]{"Stop"});
    addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
                requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
            }
        }
    });
    container = new JDialog(null, "Hello", ModalityType.MODELESS);
    container.setResizable(false);
    container.setLocationRelativeTo(null);
    container.add(this);
    this.updateUI();
    container.pack();
    container.setMinimumSize(container.getPreferredSize());
    container.setVisible(true);
    container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    container.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
        }
    });
    return container;
}
 
Example #29
Source File: ModelController.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private Window createAttributeDialog(Model model, String attributeName, String label) {
   JDialog window = new JDialog((Window) null, model.getAddress() + ": " + attributeName, ModalityType.MODELESS);
   
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(new JLabel(label), BorderLayout.NORTH);
   // TODO make this a JsonField...
   JTextPane pane = new JTextPane();
   pane.setContentType("text/html");
   pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(model.get(attributeName))));
   
   ListenerRegistration l = model.addListener((event) -> {
      if(event.getPropertyName().equals(attributeName)) {
         // TODO set background green and slowly fade out
         pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(event.getNewValue())));
      }
   });
   
   panel.add(pane, BorderLayout.CENTER);
   
   window.addWindowListener(new WindowAdapter() {
      /* (non-Javadoc)
       * @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
       */
      @Override
      public void windowClosed(WindowEvent e) {
         l.remove();
         attributeWindows.remove(model.getAddress() + ":"  + attributeName);
      }
   });
   
   return window;
}
 
Example #30
Source File: EventLogPopup.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected Window createComponent() {
   JDialog window = new JDialog(null, "Event Log", ModalityType.MODELESS);
   window.setAlwaysOnTop(false);
   window.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   // TODO remember dimensions
   window.setSize(800, 600);
   window.add(this.log.getComponent());
   return window;
}