當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。