javax.swing.JDialog#dispose ( )源码实例Demo

下面列出了javax.swing.JDialog#dispose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u_jdk   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码2 项目: PacketProxy   文件: JFontChooser.java
public int showDialog(Component parent)
{
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter()
    {
        public void windowClosing(WindowEvent e)
        {
            dialogResultValue = CANCEL_OPTION;
        }
    });

    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;

    return dialogResultValue;
}
 
源代码3 项目: openjdk-8-source   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码4 项目: TencentKona-8   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码5 项目: jmonkeyengine   文件: ErrorDialog.java
/**
 * Create a new Dialog with a title and a message.
 * @param message
 * @param title 
 */
public ErrorDialog(String message, String title) {
    setTitle(title);
    setSize(new Dimension(600, 400));
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);   
    
    Container container = getContentPane();
    container.setLayout(new BorderLayout());
    
    JTextArea textArea = new JTextArea();
    textArea.setText(message);
    textArea.setEditable(false);
    textArea.setMargin(new Insets(PADDING, PADDING, PADDING, PADDING));
    add(new JScrollPane(textArea), BorderLayout.CENTER);
    
    final JDialog dialog = this;
    JButton button = new JButton(new AbstractAction("OK"){
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    add(button, BorderLayout.SOUTH);
}
 
源代码6 项目: FancyBing   文件: GameInfoDialog.java
public static void show(Component parent, GameInfo info,
                        MessageDialogs messageDialogs)
{
    GameInfoDialog gameInfo = new GameInfoDialog(info);
    JDialog dialog = gameInfo.createDialog(parent, i18n("TIT_GAMEINFO"));
    boolean done = false;
    while (! done)
    {
        dialog.setVisible(true);
        Object value = gameInfo.getValue();
        if (! (value instanceof Integer)
            || ((Integer)value).intValue() != JOptionPane.OK_OPTION)
            return;
        done = gameInfo.validate(parent, messageDialogs);
    }
    dialog.dispose();
    gameInfo.updateGameInfo(info);
}
 
源代码7 项目: jdk8u-jdk   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码9 项目: hottub   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码10 项目: dragonwell8_jdk   文件: Test4234761.java
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
源代码11 项目: TencentKona-8   文件: Test4234761.java
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
源代码12 项目: jdk8u-jdk   文件: Test4234761.java
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
源代码13 项目: jdk8u-dev-jdk   文件: Test4234761.java
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);

    PropertyChangeListener listener = new Test4234761();
    chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name

    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    tabbedPane.setSelectedIndex(1); // HSB tab index

    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
 
源代码14 项目: FancyBing   文件: TimeLeftDialog.java
public static void show(Component parent, Game game, ConstNode node,
                        MessageDialogs messageDialogs)
{
    ConstGameInfo info = game.getGameInfoNode(node).getGameInfoConst();
    Clock clock = null;
    TimeSettings timeSettings = info.getTimeSettings();
    if (timeSettings != null)
    {
        clock = new Clock();
        clock.setTimeSettings(timeSettings);
        NodeUtil.restoreClock(node, clock);
    }
    TimeLeftDialog timeLeftDialog = new TimeLeftDialog(clock);
    JDialog dialog = timeLeftDialog.createDialog(parent,
                                                 i18n("TIT_TIME_LEFT"));
    boolean done = false;
    while (! done)
    {
        dialog.setVisible(true);
        Object value = timeLeftDialog.getValue();
        if (! (value instanceof Integer)
            || ((Integer)value).intValue() != JOptionPane.OK_OPTION)
            return;
        done = timeLeftDialog.validate(parent, messageDialogs);
    }
    for (GoColor c : BLACK_WHITE)
    {
        long timeLeft = timeLeftDialog.getTimeLeft(c);
        game.setTimeLeft(node, c, timeLeft / 1000L);
        int movesLeft = timeLeftDialog.getMovesLeft(c);
        if (movesLeft >= 0)
            game.setMovesLeft(node, c, movesLeft);
        game.restoreClock();
    }
    dialog.dispose();
}
 
源代码15 项目: triplea   文件: ForgotPasswordPanel.java
/**
 * Shows this panel in a modal dialog.
 *
 * @param parent The dialog parent window.
 * @return {@link ReturnValue#OK} if the user clicks 'okay' button, otherwise {@link
 *     ReturnValue#CANCEL}.
 */
ReturnValue show(final Window parent) {
  dialog = new JDialog(JOptionPane.getFrameForComponent(parent), title, true);
  dialog.getContentPane().add(this);
  SwingKeyBinding.addKeyBinding(dialog, KeyCode.ESCAPE, this::close);
  dialog.pack();
  dialog.setLocationRelativeTo(parent);
  dialog.setVisible(true);
  dialog.dispose();
  dialog = null;
  return returnValue;
}
 
private static void showScene(TreeScene scene, String title) {
	JScrollPane panel = new JScrollPane(scene.createView());
	JDialog dialog = new JDialog();
	dialog.setModal(true);
	dialog.setTitle(title);
	dialog.add(panel, BorderLayout.CENTER);
	dialog.setSize(800, 600);
	dialog.setVisible(true);
	dialog.dispose();
}
 
源代码17 项目: OpenDA   文件: UsernamePassword.java
/**
 * Ask using a GUI for the username and password.
 */
private void readFromGUI() {
   // Create fields for user name.
   final JTextField usernameField = new JTextField(20);
   usernameField.setText(this.username);
   final JLabel usernameLabel = new JLabel("Username: ");
   usernameLabel.setLabelFor(usernameField);
   final JPanel usernamePane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
   usernamePane.add(usernameLabel);
   usernamePane.add(usernameField);

   // Create fields for password.
   final JPasswordField passwordField = new JPasswordField(20);
   passwordField.setText(this.password);
   final JLabel passwordLabel = new JLabel("Password: ");
   passwordLabel.setLabelFor(passwordField);
   final JPanel passwordPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
   passwordPane.add(passwordLabel);
   passwordPane.add(passwordField);

   // Create panel
   final JPanel main = new JPanel();
   main.setLayout(new BoxLayout(main, BoxLayout.PAGE_AXIS));
   main.add(usernamePane);
   main.add(passwordPane);

   // Create and handle dialog
   final JOptionPane jop = new JOptionPane(main, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog = jop.createDialog("User name and password");
   dialog.addComponentListener(new ComponentAdapter() {
      
      public void componentShown(ComponentEvent e) {
         SwingUtilities.invokeLater(new Runnable() {
            
            public void run() {
               if (usernameField.getText().isEmpty())
               {
                  usernameField.requestFocusInWindow();
               }
               else
               {
                  passwordField.requestFocusInWindow();
               }
            }
         });
      }
   });
   dialog.setVisible(true);
   final Integer result = (Integer) jop.getValue();
   dialog.dispose();
   if (result.intValue() == JOptionPane.OK_OPTION) {
      this.username = usernameField.getText();

      final char[] pwd = passwordField.getPassword();
      this.password = new String(pwd);
   }
}
 
源代码18 项目: FancyBing   文件: BookmarkEditor.java
public Bookmark editItem(Component parent, String title,
                         Bookmark bookmark, boolean selectName,
                         MessageDialogs messageDialogs)
{
    JPanel panel = new JPanel(new BorderLayout(GuiUtil.SMALL_PAD, 0));
    m_panelLeft = new JPanel(new GridLayout(0, 1, 0, GuiUtil.PAD));
    panel.add(m_panelLeft, BorderLayout.WEST);
    m_panelRight =
        new JPanel(new GridLayout(0, 1, 0, GuiUtil.PAD));
    panel.add(m_panelRight, BorderLayout.CENTER);
    m_name = createEntry("LB_BOOKMARKEDITOR_NAME", 25, bookmark.m_name);
    String file = "";
    if (bookmark.m_file != null)
        file = bookmark.m_file.toString();
    m_file = createEntry("LB_BOOKMARKEDITOR_FILE", 25, file);
    String move = "";
    if (bookmark.m_move > 0)
        move = Integer.toString(bookmark.m_move);
    m_move = createEntry("LB_BOOKMARKEDITOR_MOVE", 10, move);
    m_variation = createEntry("LB_BOOKMARKEDITOR_VARIATION", 10,
                              bookmark.m_variation);
    JOptionPane optionPane = new JOptionPane(panel,
                                             JOptionPane.PLAIN_MESSAGE,
                                             JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = optionPane.createDialog(parent, title);
    boolean done = false;
    while (! done)
    {
        if (selectName)
            m_name.selectAll();
        dialog.addWindowListener(new WindowAdapter() {
                public void windowActivated(WindowEvent e) {
                    m_name.requestFocusInWindow();
                }
            });
        dialog.setVisible(true);
        Object value = optionPane.getValue();
        if (! (value instanceof Integer)
            || ((Integer)value).intValue() != JOptionPane.OK_OPTION)
            return null;
        done = validate(parent, messageDialogs);
    }
    String newName = m_name.getText().trim();
    File newFile = new File(m_file.getText());
    int newMove = getMove();
    String newVariation = m_variation.getText().trim();
    Bookmark newBookmark =
        new Bookmark(newName, newFile, newMove, newVariation);
    dialog.dispose();
    return newBookmark;
}
 
源代码19 项目: triplea   文件: ActionDurationDialog.java
private void close(final JDialog dialog) {
  dialog.setVisible(false);
  dialog.dispose();
}
 
源代码20 项目: CogniCrypt   文件: AltConfigWizard.java
/**
 * This method is called once the user selects an instance. It writes the instance to an xml file and calls the code generation.
 *
 * @return <code>true</code>/<code>false</code> if writing instance file and code generation are (un)successful
 */
@Override
public boolean performFinish() {
	boolean ret = false;
	final CodeGenerators genKind = selectedTask.getCodeGen();
	CodeGenerator codeGenerator = null;
	String additionalResources = selectedTask.getAdditionalResources();
	final LocatorPage currentPage = (LocatorPage) getContainer().getCurrentPage();
	IResource targetFile = (IResource) currentPage.getSelectedResource().getFirstElement();

	String taskName = selectedTask.getName();
	JOptionPane optionPane = new JOptionPane("CogniCrypt is now generating code that implements " + selectedTask.getDescription() + "\ninto file " + ((targetFile != null)
		? targetFile.getName()
		: "Output.java") + ". This should take no longer than a few seconds.", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}, null);
	JDialog waitingDialog = optionPane.createDialog("Generating Code");
	waitingDialog.setModal(false);
	waitingDialog.setVisible(true);
	Configuration chosenConfig = null;
	try {
		switch (genKind) {
			case CrySL:
				CrySLBasedCodeGenerator.clearParameterCache();
				File templateFile = CodeGenUtils.getResourceFromWithin(selectedTask.getCodeTemplate()).listFiles()[0];
				codeGenerator = new CrySLBasedCodeGenerator(targetFile);
				String projectRelDir = Constants.outerFileSeparator + codeGenerator.getDeveloperProject()
					.getSourcePath() + Constants.outerFileSeparator + Constants.PackageName + Constants.outerFileSeparator;
				String pathToTemplateFile = projectRelDir + templateFile.getName();
				String resFileOSPath = "";

				IPath projectPath = targetFile.getProject().getRawLocation();
				if (projectPath == null) {
					projectPath = targetFile.getProject().getLocation();
				}
				resFileOSPath = projectPath.toOSString() + pathToTemplateFile;

				Files.createDirectories(Paths.get(projectPath.toOSString() + projectRelDir));
				Files.copy(templateFile.toPath(), Paths.get(resFileOSPath), StandardCopyOption.REPLACE_EXISTING);
				codeGenerator.getDeveloperProject().refresh();

				resetAnswers();
				chosenConfig = new CrySLConfiguration(resFileOSPath, ((CrySLBasedCodeGenerator) codeGenerator).setUpTemplateClass(pathToTemplateFile));
				break;
			case XSL:
				this.constraints = (this.constraints != null) ? this.constraints : new HashMap<>();
				final InstanceGenerator instanceGenerator = new InstanceGenerator(CodeGenUtils.getResourceFromWithin(selectedTask.getModelFile())
					.getAbsolutePath(), "c0_" + taskName, selectedTask.getDescription());
				instanceGenerator.generateInstances(this.constraints);

				// Initialize Code Generation
				codeGenerator = new XSLBasedGenerator(targetFile, selectedTask.getCodeTemplate());
				chosenConfig = new XSLConfiguration(instanceGenerator.getInstances().values().iterator()
					.next(), this.constraints, codeGenerator.getDeveloperProject().getProjectPath() + Constants.innerFileSeparator + Constants.pathToClaferInstanceFile);
				break;
			default:
				return false;
		}
		ret = codeGenerator.generateCodeTemplates(chosenConfig, additionalResources);

		try {
			codeGenerator.getDeveloperProject().refresh();
		} catch (CoreException e1) {
			Activator.getDefault().logError(e1);
		}

	} catch (Exception ex) {
		Activator.getDefault().logError(ex);
	} finally {

		waitingDialog.setVisible(false);
		waitingDialog.dispose();
	}

	return ret;
}