类java.awt.Dialog.ModalityType源码实例Demo

下面列出了怎么用java.awt.Dialog.ModalityType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: arcusplatform   文件: ModelController.java
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;
}
 
源代码2 项目: openvisualtraceroute   文件: WhoIsPanel.java
/**
 * 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);

}
 
源代码3 项目: pgptool   文件: EncryptBackMultipleView.java
@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;
}
 
源代码4 项目: rapidminer-studio   文件: MacroEditor.java
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);
}
 
源代码5 项目: meka   文件: BasicSetup.java
/**
 * 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();
}
 
源代码6 项目: meka   文件: ExpertSetup.java
/**
 * 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();
}
 
源代码7 项目: FlatLaf   文件: FlatWindowDecorationsTest.java
private void openDialog() {
	Window owner = SwingUtilities.windowForComponent( this );
	JDialog dialog = new JDialog( owner, "Dialog", ModalityType.APPLICATION_MODAL );
	dialog.add( new FlatWindowDecorationsTest() );
	dialog.pack();
	dialog.setLocationRelativeTo( this );
	dialog.setVisible( true );
}
 
源代码8 项目: arcusplatform   文件: EventLogPopup.java
@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;
}
 
源代码9 项目: arcusplatform   文件: ModelController.java
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;
}
 
源代码10 项目: pgptool   文件: CreateKeyView.java
@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;
}
 
源代码11 项目: pgptool   文件: KeyImporterView.java
@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;
}
 
源代码12 项目: pgptool   文件: EncryptTextView.java
@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;
}
 
源代码13 项目: pgptool   文件: DecryptOneDialogView.java
@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;
}
 
源代码14 项目: pgptool   文件: CheckForUpdatesView.java
@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;
}
 
源代码15 项目: pgptool   文件: AboutView.java
@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;
}
 
源代码16 项目: pgptool   文件: GetKeyPasswordDialogView.java
@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;
}
 
源代码17 项目: pgptool   文件: KeysListView.java
@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;
}
 
源代码18 项目: pgptool   文件: DecryptTextView.java
@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;
}
 
源代码19 项目: pgptool   文件: DialogViewBaseCustom.java
@Override
protected void showDialog(Window optionalParent) {
	super.showDialog(optionalParent);
	if (dialog.getModalityType() == ModalityType.MODELESS) {
		UiUtils.makeSureWindowBroughtToFront(dialog);
	}
}
 
源代码20 项目: pgptool   文件: EncryptOneView.java
@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;
}
 
源代码21 项目: gcs   文件: UIUtilities.java
/** @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;
}
 
/**
 * 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;
}
 
/**
 * 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);
		}
	}
}
 
源代码24 项目: rapidminer-studio   文件: BetaFeaturesListener.java
@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");
		}
	}
}
 
源代码25 项目: open-ig   文件: AnimPlay.java
/**
 * 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;
}
 
源代码26 项目: open-ig   文件: AnimPlay.java
/**
 * 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;
}
 
源代码27 项目: procamcalib   文件: MainFrame.java
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);
    }
}
 
源代码28 项目: RipplePower   文件: SwingUtils.java
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;
}
 
源代码29 项目: CodeChickenCore   文件: DepLoader.java
@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;
}
 
源代码30 项目: procamtracker   文件: MainFrame.java
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);
    }
}
 
 类所在包
 同包方法