当前位置: 首页>>代码示例>>Java>>正文


Java JDialog.setDefaultCloseOperation方法代码示例

本文整理汇总了Java中javax.swing.JDialog.setDefaultCloseOperation方法的典型用法代码示例。如果您正苦于以下问题:Java JDialog.setDefaultCloseOperation方法的具体用法?Java JDialog.setDefaultCloseOperation怎么用?Java JDialog.setDefaultCloseOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JDialog的用法示例。


在下文中一共展示了JDialog.setDefaultCloseOperation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import javax.swing.JDialog; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
// FIXME: don't create a new one each time!
      final File logfile = new File(Info.getHomeDir(), "errorLog");
      final LogPane lp = new LogPane(logfile);

// FIXME: this should have its own key. Probably keys should be renamed
// to reflect what they are labeling, e.g., Help.show_error_log_menu_item,
// Help.error_log_dialog_title.
      final JDialog d =
        new JDialog(frame, Resources.getString("Help.error_log"));
      d.setLayout(new MigLayout("insets 0"));
      d.add(new JScrollPane(lp), "grow, push, w 500, h 600");

      d.setLocationRelativeTo(frame);
      d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

      d.pack();
      d.setVisible(true);
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:ModuleManagerWindow.java

示例2: createDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Creates and returns a fresh dialog for the given frame.
 */
private JDialog createDialog(Component frame) {
    Object[] buttons = new Object[] {getOkButton(), getCancelButton()};
    JPanel input = new JPanel();
    input.setLayout(new BorderLayout());
    input.add(getChoiceBox(), BorderLayout.NORTH);
    // add an error label if there is a parser
    if (this.parsed) {
        JPanel errorPanel = new JPanel(new BorderLayout());
        errorPanel.add(getErrorLabel());
        input.add(errorPanel, BorderLayout.SOUTH);
    }
    JPanel main = new JPanel();
    main.setLayout(new BorderLayout());
    main.add(input, BorderLayout.CENTER);
    if (this.parsed) {
        main.add(createSyntaxPanel(), BorderLayout.EAST);
    }
    JOptionPane panel = new JOptionPane(main, JOptionPane.PLAIN_MESSAGE,
        JOptionPane.OK_CANCEL_OPTION, null, buttons);
    JDialog result = panel.createDialog(frame, this.title);
    result.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    result.addWindowListener(this.closeListener);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:28,代码来源:FormulaDialog.java

示例3: createDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Creates and returns a fresh dialog for the given frame.
 */
private JDialog createDialog(Component frame) {
    Object[] buttons = new Object[] {getOkButton(), getCancelButton()};
    // input panel with text area and choice box
    JPanel input = new JPanel();
    input.setLayout(new BorderLayout());
    input.setPreferredSize(new Dimension(300, 150));
    input.add(new JLabel("<html><b>Enter value:"), BorderLayout.NORTH);
    input.add(new JScrollPane(getTextArea()), BorderLayout.CENTER);
    input.add(getChoiceBox(), BorderLayout.SOUTH);
    JPanel main = new JPanel();
    main.setLayout(new BorderLayout());
    main.add(input, BorderLayout.CENTER);
    if (this.parsed) {
        JPanel errorPanel = new JPanel(new BorderLayout());
        errorPanel.add(getErrorLabel());
        main.add(errorPanel, BorderLayout.SOUTH);
        main.add(createSyntaxPanel(), BorderLayout.EAST);
    }
    JOptionPane panel = new JOptionPane(main, JOptionPane.PLAIN_MESSAGE,
        JOptionPane.OK_CANCEL_OPTION, null, buttons);
    JDialog result = panel.createDialog(frame, this.title);
    result.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    result.addWindowListener(this.closeListener);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:29,代码来源:StringDialog.java

示例4: createCancelDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Creates a modal dialog that will interrupt this thread, when the
 * cancel button is pressed.
 */
private JDialog createCancelDialog() {
    JDialog result;
    // create message dialog
    JOptionPane message = new JOptionPane(
        isAnimated() ? getAnimationPanel()
            : new Object[] {getStateCountLabel(), getTransitionCountLabel()},
        JOptionPane.PLAIN_MESSAGE);
    message.setOptions(new Object[] {getCancelButton()});
    result = message.createDialog(getFrame(), "Exploring state space");
    result.pack();
    result.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    result.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            ExploreThread.this.interrupt();
        }
    });
    result.setAlwaysOnTop(true);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:25,代码来源:ExploreAction.java

示例5: setupUI

import javax.swing.JDialog; //导入方法依赖的package包/类
private void setupUI() {
    dialog = new JDialog();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(200, 100);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);

    JPopupMenu popup = new JPopupMenu();
    popup.add(new JMenuItem("one"));
    JMenuItem two = new JMenuItem("two");
    two.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            passed = true;
        }
    });
    popup.add(two);
    popup.add(new JMenuItem("three"));
    popup.show(dialog, 50, 50);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:bug6544309.java

示例6: open

import javax.swing.JDialog; //导入方法依赖的package包/类
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog)dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ProgressPanel.java

示例7: open

import javax.swing.JDialog; //导入方法依赖的package包/类
public void open(JComponent progressComponent) {
    holder.add(progressComponent, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage (ProgressPanel.class, "MSG_PleaseWait"),
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null,
            true);
    dialog = DialogDisplayer.getDefault().createDialog(dd);
    if (dialog instanceof JDialog) {
        JDialog jDialog = ((JDialog)dialog);
        jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        JRootPane rootPane = jDialog.getRootPane();
        rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
        rootPane.getActionMap().put("cancel", new AbstractAction() { // NOI18N
            public void actionPerformed(ActionEvent event) {
                if (cancelButton.isEnabled()) {
                    cancelButton.doClick();
                }
            }
        });
    }
    dialog.setResizable(false);
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ProgressPanel.java

示例8: main

import javax.swing.JDialog; //导入方法依赖的package包/类
public static void main(String[] ignore) {
    boolean[] adv = {false, true};
    for (int j = 0; j < adv.length; j++) {
        JDialog dlg = new JDialog((Frame) null, "advancedMode=" + adv[j], false); // NOI18N
        dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        TargetMappingPanel panel = new TargetMappingPanel(adv[j]);
        panel.setTargetNames(new ArrayList<String>(Arrays.asList("build", "clean", "test")), true); // NOI18N
        dlg.getContentPane().add(panel);
        dlg.pack();
        dlg.setSize(700, 500);
        dlg.setVisible(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TargetMappingPanel.java

示例9: getProgressMonitorContainer

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Returns the progress monitor container that is either a JDialog or a JInternFrame.
 * @return the progress monitor container
 */
private Container getProgressMonitorContainer() {
	if (progressMonitorContainer==null) {
		
		Dimension defaultSize = new Dimension(570, 188);
		if (this.parentDesktopPane==null) {
			JDialog jDialog = new JDialog(this.owner);	
			jDialog.setSize(defaultSize);
			jDialog.setResizable(false);
			if (this.owner==null) {
				jDialog.setAlwaysOnTop(true);
			}
			jDialog.setTitle(this.windowTitle);
			if (this.iconImage!=null) {
				jDialog.setIconImage(this.iconImage.getImage());	
			}
			jDialog.setContentPane(this.getJContentPane());
			jDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
			
			this.progressMonitorContainer = jDialog; 
			this.setLookAndFeel();	
				
		} else {
			JInternalFrame jInternalFrame = new JInternalFrame();
			jInternalFrame.setSize(defaultSize);
			jInternalFrame.setResizable(false);
			
			jInternalFrame.setTitle(this.windowTitle);
			if (this.iconImage!=null) {
				jInternalFrame.setFrameIcon(this.iconImage);	
			}
			jInternalFrame.setContentPane(this.getJContentPane());
			jInternalFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
			
			this.progressMonitorContainer = jInternalFrame;
		}
		
	}
	return progressMonitorContainer;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:44,代码来源:ProgressMonitor.java

示例10: main

import javax.swing.JDialog; //导入方法依赖的package包/类
public static void main(String[] args) {
  final String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

  final JDialog d = new JDialog();
  d.setTitle("Flow Label Test");
  d.setModal(true);
  d.setResizable(true);
  d.setLocationRelativeTo(null);
  d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  d.add(new FlowLabel(loremIpsum + "\n\n" + loremIpsum));
  d.pack();
  d.setVisible(true);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:FlowLabel.java

示例11: show

import javax.swing.JDialog; //导入方法依赖的package包/类
/** Shows a given graph in an optionally modal dialog. */
private void show(final Graph graph, GrammarModel grammar, boolean modal) {
    GraphPreviewPanel panel = GraphPreviewDialog.createPanel(grammar, graph);
    panel.add(new NodeIdsButton(panel), BorderLayout.NORTH);
    JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE);
    JDialog dialog = optionPane.createDialog(graph.getName());
    dialog.setModal(modal);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:Viewer.java

示例12: saveSEGY

import javax.swing.JDialog; //导入方法依赖的package包/类
private void saveSEGY(OutputStream out) throws IOException {
	if(image==null) throw new IOException("no image loaded");

	String mcsPath = PathUtil.getPath("PORTALS/MULTI_CHANNEL_PATH",
			MapApp.BASE_URL+"/data/portals/mcs/");

	URL url = URLFactory.url( mcsPath + line.getCruiseID().trim() + "/segy/" +
			line.getCruiseID().trim() +"-"+ 
			line.getID().trim() + ".segy" );
	URLConnection urlCon = url.openConnection();
	BufferedInputStream in = new BufferedInputStream(urlCon.getInputStream());
	int length = urlCon.getContentLength();

	// Create a JProgressBar + JDialog
	JDialog d = new JDialog((Frame)null, "Saving SEGY");
	JPanel p = new JPanel(new BorderLayout());
	p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
	d.setLocationRelativeTo(null);
	JProgressBar pb = new JProgressBar(0,length);
	p.add(new JLabel("Saving " + (length / 1000000) + "mb segy file"), BorderLayout.NORTH);
	p.add(pb);
	d.getContentPane().add(p);

	d.pack();
	d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	d.setVisible(true);

	byte[] b = new byte[16384];
	int read = in.read(b);
	while (read != -1) {
		out.write(b, 0, read);
		pb.setValue(pb.getValue() + read);
		pb.repaint();
		read = in.read(b);
	}

	out.flush();
	in.close();
	d.dispose();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:41,代码来源:XMImage.java

示例13: actionPerformed

import javax.swing.JDialog; //导入方法依赖的package包/类
public void actionPerformed( final ActionEvent e ) {
    String command = e.getActionCommand();

    if ( COMMAND_OK.equals( command ) ) {
        // Call the OK option listener
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
            public Object run() {
                okOptionListener.actionPerformed( e ); // XXX maybe create new event
                actionPerformed(e, categories);
                return null;
            }
        });
        
        final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress"));
        JComponent component = ProgressHandleFactory.createProgressComponent(handle);
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        final JDialog dialog = new JDialog(mainWindow, 
                NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true);
        SavingProjectDataPanel panel = new SavingProjectDataPanel(component);
        
        dialog.getContentPane().add(panel);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        dialog.pack();
        
        Rectangle bounds = mainWindow.getBounds();
        int middleX = bounds.x + bounds.width / 2;
        int middleY = bounds.y + bounds.height / 2;
        Dimension size = dialog.getPreferredSize();
        dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height);
        
        // Call storeListeners out of AWT EQ
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                try {
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
                        @Override
                        public Object run() {
                            FileUtil.runAtomicAction(new Runnable() {
                                @Override
                                public void run() {
                            handle.start();
                            if (storeListener != null) {
                                storeListener.actionPerformed(e);
                            }
                            storePerformed(e, categories);
                            // #97998 related
                            saveModifiedProject();
                                }
                            });
                            return null;
                        }
                    });
                } finally {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            dialog.setVisible(false);
                            dialog.dispose();
                        }
                    });
                }
            }
        });
        
        dialog.setVisible(true);
        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:CustomizerDialog.java

示例14: run

import javax.swing.JDialog; //导入方法依赖的package包/类
/**
 * Run the app.
 * @param root root of the phadhail tree to add test data to
 * @param app application frame (may be null)
 */
public static void run(final File root, Frame app) {
    String msg = "How many files should I create?";
    String title = "Choose Size of Test Data";
    Integer[] sizes = new Integer[] {
        new Integer(5),
        new Integer(10),
        new Integer(25),
        new Integer(50),
        new Integer(100),
        new Integer(250),
        new Integer(500),
        new Integer(1000),
        new Integer(2500),
        new Integer(5000),
        new Integer(10000),
        new Integer(25000),
    };
    Integer def = new Integer(500);
    Integer i = (Integer)JOptionPane.showInputDialog(null, msg, title,
                                                     JOptionPane.QUESTION_MESSAGE,
                                                     null, sizes, def);
    if (i == null) {
        // Cancelled.
        return;
    }
    final int val = i.intValue();
    final JProgressBar progress = new JProgressBar(0, val);
    final JDialog dialog = new JDialog(app, "Creating test files...", true);
    dialog.getContentPane().setLayout(new FlowLayout());
    JLabel label = new JLabel("Creating files:");
    label.setLabelFor(progress);
    dialog.getContentPane().add(label);
    dialog.getContentPane().add(progress);
    dialog.pack();
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    new Thread(new Runnable() {
        public void run() {
            try {
                create(root, val, progress.getModel());
            } catch (IOException e) {
                e.printStackTrace();
            }
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    dialog.setVisible(false);
                }
            });
        }
    }, "Populating test files").start();
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:57,代码来源:Populate.java

示例15: showOptionDialog

import javax.swing.JDialog; //导入方法依赖的package包/类
protected int showOptionDialog(JFrame mainFrame, String message,
                               String title, String[] options, int defaultValue) {
    final IntHolder holder = new IntHolder();
    final JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    holder.value = defaultValue;
    JPanel panel = new JPanel(new BorderLayout());
    JPanel m = new JPanel(new FlowLayout());
    m.add(new JLabel(message));
    panel.add(m, BorderLayout.CENTER);
    JPanel bottom = new JPanel(new GridLayout(1, 3, 5, 7));
    int i = 0;
    for (String s : options) {
        final int r = i;
        JButton button = new JButton(new AbstractAction(s) {
            /**
             *
             */
            private static final long serialVersionUID = 7269041268620864162L;

            @Override
            public void actionPerformed(ActionEvent e) {
                holder.value = r;
                dialog.setVisible(false);
            }
        });
        i++;
        bottom.add(button);
    }
    JPanel p = new JPanel(new FlowLayout());
    p.add(bottom);

    panel.add(p, BorderLayout.SOUTH);
    JPanel pane = new JPanel(new FlowLayout());
    pane.add(panel);
    dialog.setTitle(title);
    dialog.setContentPane(pane);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);
    return holder.value;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:44,代码来源:FilePlugin.java


注:本文中的javax.swing.JDialog.setDefaultCloseOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。