本文整理了Java中javax.swing.JDialog.setDefaultCloseOperation()
方法的一些代码示例,展示了JDialog.setDefaultCloseOperation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JDialog.setDefaultCloseOperation()
方法的具体详情如下:
包路径:javax.swing.JDialog
类名称:JDialog
方法名:setDefaultCloseOperation
暂无
代码示例来源:origin: libgdx/libgdx
regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(regionPickerPanel);
regionSelectDialog.setContentPane(scrollPane);
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);
代码示例来源:origin: stackoverflow.com
final JOptionPane optionPane = new JOptionPane("Hello world", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
final JDialog dialog = new JDialog();
dialog.setTitle("Message");
dialog.setModal(true);
dialog.setContentPane(optionPane);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.pack();
//create timer to dispose of dialog after 5 seconds
Timer timer = new Timer(5000, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
dialog.dispose();
}
});
timer.setRepeats(false);//the timer should only go off once
//start timer to close JDialog as dialog modal we must start the timer before its visible
timer.start();
dialog.setVisible(true);
代码示例来源:origin: stackoverflow.com
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
passSomeTime();
this.setVisible(false);
this.dispatchEvent(new WindowEvent(
this, WindowEvent.WINDOW_CLOSING));
代码示例来源:origin: stackoverflow.com
mainPanel.add(new JButton(new MyAction(frame, JDialog.DISPOSE_ON_CLOSE, "DISPOSE_ON_CLOSE")));
mainPanel.add(new JButton(new MyAction(frame, JDialog.HIDE_ON_CLOSE, "HIDE_ON_CLOSE")));
mainPanel.add(new JButton(new MyAction(frame, JDialog.DO_NOTHING_ON_CLOSE, "DO_NOTHING_ON_CLOSE")));
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
dialog = new JDialog(frame, title, false);
dialog.setDefaultCloseOperation(defaultCloseOp);
dialog.setPreferredSize(new Dimension(300, 200));
dialog.pack();
dialog.addWindowListener(new WindowAdapter() {
@Override
dialog.setVisible(true);
代码示例来源:origin: org.netbeans.api/org-openide-util
dialog = new javax.swing.JDialog(parentDlg, title, true);
} else {
dialog = new javax.swing.JDialog(frame, title, true);
dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
contentPane.add(chooser, BorderLayout.CENTER);
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public void run() {
StringBuilder sb = new StringBuilder("<p>There were errors:</p><table border=1 cellspacing=1 cellpadding=1>");
for (ObjectName on : result.keySet()) {
Throwable t = ExceptionHelper.getRootCause(result.get(on));
appContext.log(t);
sb.append("<tr><td>");
sb.append(on.getKeyProperty("name"));
sb.append(":");
sb.append("</td><td>");
sb.append(t.getLocalizedMessage());
sb.append("</td></tr>");
}
sb.append("</table>");
setMsgText(sb.toString());
JButton btn = new JButton("Close");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
waitDialog.setVisible(false);
}
});
JPanel btnPanel = new JPanel(new FlowLayout());
btnPanel.add(btn);
waitDialog.getContentPane().add(btnPanel, BorderLayout.SOUTH);
waitDialog.getRootPane().setWindowDecorationStyle(JRootPane.ERROR_DIALOG);
waitDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Dimension size = waitDialog.getSize();
waitDialog.pack();
waitDialog.setSize(size);
}
});
代码示例来源:origin: stackoverflow.com
dialog.setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
JButton button = new JButton("Hit me!");
button.addActionListener(new ActionListener()
代码示例来源:origin: org.cytoscape/vizmap-gui-impl
private void initComponents(final JDialog dialog) {
dialog.setLayout(new BorderLayout());
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.getContentPane().add(editorPanel, BorderLayout.CENTER);
dialog.setPreferredSize(DEF_SIZE);
dialog.setMinimumSize(MIN_SIZE);
dialog.pack();
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
public void run() {
if (progressLabel == null) initComponents();
DialogDescriptor dd = createDialogDescriptor(caption, message, controller);
Dialog d = DialogDisplayer.getDefault().createDialog(dd);
d.pack();
owner = d;
if (owner instanceof JDialog) {
((JDialog)owner).setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
}
d.setVisible(true);
}
});
代码示例来源:origin: stackoverflow.com
import javax.swing.JDialog;
import javax.swing.JFrame;
public class MyDialog {
private JFrame frame = new JFrame();
private JDialog dialog = new JDialog();
public MyDialog() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
//dialog = new JDialog(frame, JDialog.ModalityType.TOOLKIT_MODAL);
dialog = new JDialog(frame, true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setModal(true);
dialog.setSize(300, 200);
dialog.setVisible(true);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
MyDialog dialog = new MyDialog();
}
});
}
}
代码示例来源:origin: stackoverflow.com
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
pack();
@Override
public void run() {
new CustomDialog(null, "David").setVisible(true);
代码示例来源:origin: stackoverflow.com
this.add(new JLabel("Dialog close test.", JLabel.CENTER));
this.add(new JButton(new AbstractAction("Close") {
DialogClose.this.setVisible(false);
DialogClose.this.dispatchEvent(new WindowEvent(
DialogClose.this, WindowEvent.WINDOW_CLOSING));
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
代码示例来源:origin: geotools/geotools
frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
((JDesktopPane) owner).add(frame);
frame.getContentPane().add(panel);
frame.pack();
return frame;
final JDialog dialog = new JDialog((Frame) owner, title);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.addWindowListener(listener);
dialog.getContentPane().add(panel);
dialog.pack();
return dialog;
final JDialog dialog = new JDialog((Dialog) owner, title);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.addWindowListener(listener);
dialog.getContentPane().add(panel);
dialog.pack();
return dialog;
代码示例来源:origin: libgdx/libgdx
regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(regionPickerPanel);
regionSelectDialog.setContentPane(scrollPane);
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);
代码示例来源:origin: magefree/mage
JDialog d = new JDialog((Frame) null, "Download symbols", false);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.addWindowListener(new WindowAdapter() {
@Override
代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui
private void initGUI() {
JLabel label = new JLabel(this.message, SwingConstants.CENTER);
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
WaitDialog.this.dialog.hide();
WaitDialog.this.cancelable.cancel();
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(cancelButton);
this.dialog = new XBayaDialog(this.xbayaGUI, this.title, label, buttonPanel);
this.dialog.getDialog().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.dialog.getDialog().setCursor(SwingUtil.WAIT_CURSOR);
this.dialog.getDialog().addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
shown();
}
});
}
代码示例来源:origin: stackoverflow.com
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
try {
DummyDialog d = new DummyDialog();
d.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
代码示例来源:origin: stackoverflow.com
import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.JDialog;
public class WhyNoDispose extends JDialog {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
WhyNoDispose frame = new WhyNoDispose("my title");
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public WhyNoDispose(String title) {
super((JFrame)null, title);
pack();
}
}
代码示例来源:origin: stackoverflow.com
initComponents(frame);
frame.setPreferredSize(new Dimension(300, 300));//testing purposes
frame.pack();
frame.setVisible(true);
final JDialog emailDialog = new JDialog(frame);
emailDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
emailDialog.setLayout(new BorderLayout());
JButton sendMailBtn = new JButton("Send Email");
sendMailBtn.addActionListener(new ActionListener() {
final JDialog emailProgressDialog = new JDialog(frame);
emailProgressDialog.add(new JLabel("Mail in progress"));
emailProgressDialog.pack();
emailProgressDialog.setVisible(true);
emailDialog.add(sendMailBtn, BorderLayout.SOUTH);
emailDialog.pack();
JButton openDialog = new JButton("Open emailDialog");
openDialog.addActionListener(new ActionListener() {
emailDialog.setVisible(true);
frame.getContentPane().add(openDialog);
代码示例来源:origin: org.netbeans.api/org-openide-util-ui
dialog = new javax.swing.JDialog(parentDlg, title, true);
} else {
dialog = new javax.swing.JDialog(frame, title, true);
dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
contentPane.add(chooser, BorderLayout.CENTER);
内容来源于网络,如有侵权,请联系作者删除!