Example usage for javax.swing JDialog JDialog

List of usage examples for javax.swing JDialog JDialog

Introduction

In this page you can find the example usage for javax.swing JDialog JDialog.

Prototype

public JDialog(Window owner, String title) 

Source Link

Document

Creates a modeless dialog with the specified title and owner Window .

Usage

From source file:Main.java

private static JDialog dialogRaw(String title, final Window frame, ModalityType modal) {
    final JDialog dialog = new JDialog(frame, modal);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle(title);//from   w  w  w  . j a  va  2 s.  c o m
    return dialog;
}

From source file:Main.java

static public JDialog addModelessWindow(Window mainWindow, Component jpanel, String title) {
    JDialog dialog;/*from w  w w .j  a v  a  2 s  .  c om*/
    if (mainWindow != null) {
        dialog = new JDialog(mainWindow, title);
    } else {
        dialog = new JDialog();
        dialog.setTitle(title);
    }
    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;
}

From source file:Main.java

public Main() {
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);/*from w  ww  .ja  v a2s  .  c  om*/
    frame.setVisible(true);
    dialog = new JDialog(frame, true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    dialog.setSize(300, 200);
    dialog.setVisible(true);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(300, 200);/*  ww w  . j  ava 2 s  .co m*/
    blocker = new JDialog(this, true);
    blocker.setLayout(new FlowLayout());
    blocker.add(new JLabel("I'm blocking EDT!"));
    JProgressBar progress = new JProgressBar();
    progress.setIndeterminate(true);
    blocker.add(progress);
    blocker.pack();

    timer = new Timer(3000, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSomeWork();
        }
    });
    timer.setRepeats(false);
    timer.start();
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JButton openDialog = new JButton("Click here");
    JPanel myPanel = new JPanel();
    myPanel.add(new JButton(new AbstractAction("Click here") {
        @Override/*w w w. j a va2  s .  c om*/
        public void actionPerformed(ActionEvent e) {
            JDialog dialog = new JDialog(myFrame, true);
            JTextField myField = new JTextField(10);
            JPanel innerPanel = new JPanel();
            innerPanel.add(myField);
            dialog.add(innerPanel);
            dialog.pack();
            dialog.setSize(new Dimension(160, 120));
            dialog.setLocationRelativeTo(myFrame);
            dialog.setVisible(true);
        }
    }));
    add(myPanel);
    pack();
    setSize(new Dimension(320, 240));
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:Main.java

public Main() {
    int MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();

    KeyStroke exitKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, MASK);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);

    JMenu fileMenu = new JMenu("File");
    JMenuItem fileExit = new JMenuItem(exitAction);
    fileMenu.add(fileExit);// w w w.  java  2 s .  c  o  m
    JMenuBar menu = new JMenuBar();
    menu.add(fileMenu);

    JDialog d = new JDialog(this, "Dialog");
    JPanel p = new JPanel();
    p.getInputMap().put(exitKey, exitName);
    p.getActionMap().put(exitName, exitAction);
    p.add(new JButton(exitAction));
    d.add(p);
    d.pack();
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    this.setJMenuBar(menu);
    this.pack();
    this.setSize(new Dimension(320, 240));
    this.setVisible(true);
    d.setLocation(this.getRootPane().getContentPane().getLocationOnScreen());
    d.setVisible(true);
}

From source file:org.nekorp.workflow.desktop.view.resource.imp.EvidenciaViewDialogFactory.java

@Override
public JDialog createDialog(Frame frame, boolean modal) {
    JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle("Evidencia");
    evidenciaView.iniciaVista();/*  ww  w . ja  va 2s .  com*/
    dialog.add(evidenciaView);
    dialog.setSize(980, 640);//hardcode para que no cresca en medida de imagenes en el preview
    dialog.validate();
    //dialog.pack();
    dialog.setLocationRelativeTo(mainFrame);
    return dialog;
}

From source file:org.nekorp.workflow.desktop.view.resource.imp.ParametrosReporteGlobalDialogFactory.java

@Override
public JDialog createDialog(Frame frame, boolean modal) {
    JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle("Reporte Global");
    datePickView.setParent(dialog);//from w w  w.  j a  v  a  2 s  .c  om
    datePickView.iniciaVista();
    dialog.add(datePickView);
    dialog.validate();
    dialog.pack();
    dialog.setLocationRelativeTo(mainFrame);
    return dialog;
}

From source file:org.nekorp.workflow.desktop.view.resource.imp.DamageCaptureDetailDialogFactory.java

@Override
public JDialog createDialog(Frame frame, boolean modal) {
    JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle("Descripcin del Dao");
    view.setParentWindow(dialog);/*from w  w  w  .  j  av a 2 s  .  com*/
    view.iniciaVista();
    dialog.add(view);
    dialog.validate();
    dialog.pack();
    dialog.setLocationRelativeTo(mainFrame);
    return dialog;
}

From source file:org.nekorp.workflow.desktop.view.resource.imp.WizardDialogFactory.java

@Override
public JDialog createDialog(Frame frame, boolean modal) {
    JDialog dialog = new JDialog(mainFrame, true);
    dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setTitle("Nuevo Servicio");
    wizard.setParentWindow(dialog);//from  w ww. j  ava  2s  . c  o  m
    wizard.iniciaVista();
    dialog.add(wizard);
    dialog.validate();
    dialog.pack();
    dialog.setLocationRelativeTo(mainFrame);
    return dialog;
}