javax.swing.JDialog.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中javax.swing.JDialog.<init>()方法的一些代码示例,展示了JDialog.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JDialog.<init>()方法的具体详情如下:
包路径:javax.swing.JDialog
类名称:JDialog
方法名:<init>

JDialog.<init>介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

private void initAboutBox() {
 aboutBox = new JDialog(this, "About Tregex");
 aboutBox.getContentPane().setLayout(new BorderLayout());
 aboutBox.getContentPane().add(new JLabel("<html><b>Tregex and Tsurgeon</b></html>", SwingConstants.CENTER), BorderLayout.NORTH);
 aboutBox.getContentPane().add(new JLabel("<html>Tregex by Galen Andrew and Roger Levy<br>Tsurgeon by Roger Levy<br>Graphical interface by Anna Rafferty<br>Additional features and development by Chris Manning<br></html>", SwingConstants.CENTER), BorderLayout.CENTER);
 aboutBox.getContentPane().add(new JLabel("<html><font size=2>\u00A92007 The Board of Trustees of The Leland Stanford Junior University.<br>Distributed under the GNU General Public License</font></html>", SwingConstants.CENTER), BorderLayout.SOUTH);
}

代码示例来源:origin: stackoverflow.com

final JDialog d = new JDialog();
d.setSize(200,200);
d.setLocationRelativeTo(null);
d.setVisible(true);

代码示例来源:origin: libgdx/libgdx

regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);

代码示例来源:origin: deathmarine/Luyten

protected JDialog createDialog(Component parent) {
  Frame frame = parent instanceof Frame ? (Frame) parent
      : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
  JDialog dialog = new JDialog(frame, ("Select Font"), true);
  Action okAction = new DialogOKAction(dialog);
  Action cancelAction = new DialogCancelAction(dialog);
  JButton okButton = new JButton(okAction);
  okButton.setFont(DEFAULT_FONT);
  JButton cancelButton = new JButton(cancelAction);
  cancelButton.setFont(DEFAULT_FONT);
  JPanel buttonsPanel = new JPanel();
  buttonsPanel.setLayout(new GridLayout(2, 1));
  buttonsPanel.add(okButton);
  buttonsPanel.add(cancelButton);
  buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
  ActionMap actionMap = buttonsPanel.getActionMap();
  actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
  actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
  InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
  inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
  JPanel dialogEastPanel = new JPanel();
  dialogEastPanel.setLayout(new BorderLayout());
  dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
  dialog.getContentPane().add(this, BorderLayout.CENTER);
  dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
  dialog.pack();
  dialog.setLocationRelativeTo(frame);
  return dialog;
}

代码示例来源:origin: stackoverflow.com

JButton showWaitBtn = new JButton(new ShowWaitAction("Show Wait Dialog"));
JPanel panel = new JPanel();
panel.add(showWaitBtn);
JFrame frame = new JFrame("Frame");
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
final JDialog dialog = new JDialog(win, "Dialog", ModalityType.APPLICATION_MODAL);
JPanel panel = new JPanel(new BorderLayout());
panel.add(progressBar, BorderLayout.CENTER);
panel.add(new JLabel("Please wait......."), BorderLayout.PAGE_START);
dialog.add(panel);
dialog.pack();
dialog.setLocationRelativeTo(win);
dialog.setVisible(true);

代码示例来源:origin: kiegroup/optaplanner

public ConferenceCFPImportWorker(SolutionBusiness<ConferenceSolution> solutionBusiness,
    SolutionPanel<ConferenceSolution> solutionPanel, String conferenceBaseUrl) {
  this.solutionBusiness = solutionBusiness;
  this.solutionPanel = solutionPanel;
  this.conferenceBaseUrl = conferenceBaseUrl;
  dialog = new JDialog(solutionPanel.getSolverAndPersistenceFrame(), true);
  JPanel contentPane = new JPanel(new BorderLayout(10, 10));
  contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  contentPane.add(new JLabel("Importing CFP data in progress..."), BorderLayout.NORTH);
  JProgressBar progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
  progressBar.setIndeterminate(true);
  contentPane.add(progressBar, BorderLayout.CENTER);
  JButton button = new JButton("Cancel");
  button.addActionListener(e -> cancel(false));
  contentPane.add(button, BorderLayout.SOUTH);
  dialog.setContentPane(contentPane);
  dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  dialog.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e) {
      cancel(false);
    }
  });
  dialog.pack();
  dialog.setLocationRelativeTo(solutionPanel.getSolverAndPersistenceFrame());
}

代码示例来源:origin: stanfordnlp/CoreNLP

final JDialog dialog = new JDialog(frame, "Jar File Chooser", true);
dialog.setLocation(location);
final JList fileList = new JList(new Vector<>(files));
JButton okay = new javax.swing.JButton();
okay.setText("Okay");
okay.setToolTipText("Okay");
okay.addActionListener(evt -> dialog.setVisible(false));
JButton cancel = new javax.swing.JButton();
cancel.setText("Cancel");
cancel.setToolTipText("Cancel");
cancel.addActionListener(evt -> {
 fileList.clearSelection();
 dialog.setVisible(false);
});
dialog.pack();
dialog.setSize(dialog.getPreferredSize());
dialog.setVisible(true);

代码示例来源:origin: stackoverflow.com

import javax.swing.*;
import java.awt.*;
public class t {

  public static void main(String[] args) {
    JDialog downloadingDialog = new JDialog((JFrame)null ,"Start donwloading...");
    JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setIndeterminate(true);
    downloadingDialog.setLayout(new FlowLayout(FlowLayout.LEFT));
    downloadingDialog.add(progressBar);
    downloadingDialog.setSize(300, 100);
    downloadingDialog.setVisible(true);
  }
}

代码示例来源:origin: stackoverflow.com

import javax.swing.*;

class CenterTheDialog {

  CenterTheDialog() {
    for (int ii=1; ii<4; ii++) {
      JFrame f = new JFrame("Frame " + ii);
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      f.setSize(400,300);
      f.setLocationByPlatform(true);
      f.setVisible(true);

      JDialog d = new JDialog(f);
      d.setSize(300,200);
      d.setLocationRelativeTo(f);
      d.setVisible(true);
    }
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new CenterTheDialog();
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Test {

  public static void main(String[] args) {
    JFrame f = new JFrame();
    final JDialog dialog = new JDialog(f, "Test", true);
    Timer timer = new Timer(2000, new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        dialog.setVisible(false);
        dialog.dispose();
      }
    });
    timer.setRepeats(false);
    timer.start();

    dialog.setVisible(true); // if modal, application will pause here

    System.out.println("Dialog closed");
  }
}

代码示例来源:origin: stackoverflow.com

import javax.swing.JDialog;
import javax.swing.JFrame;

public class DialogAndDaemons {
  public static void main(String[] args) {
   JFrame frame = new JFrame();

   JDialog dialog = new JDialog(frame, "Dialog");
   dialog.pack();
   dialog.setLocationRelativeTo(null);
   dialog.setVisible(true);
  }
}

代码示例来源:origin: cmusphinx/sphinx4

public VUMeterMonitor() {
  vumeter = new VUMeter();
  vuMeterPanel = new VUMeterPanel();
  vuMeterPanel.setVu(vumeter);
  vuMeterPanel.start();
  vuMeterDialog = new JDialog();
  vuMeterDialog.setBounds(100, 100, 100, 400);
  vuMeterDialog.getContentPane().setLayout(new BorderLayout());
  vuMeterDialog.getContentPane().add(vuMeterPanel);
  vuMeterDialog.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

frame.getContentPane().add(new MyFramePanel());
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.pack();
 frame.setLocationRelativeTo(null);
 frame.setVisible(true);
private JButton openDialogeBtn = new JButton("Open Dialog");
 field.setFocusable(false);
 add(field);
 add(openDialogeBtn);
   Window win = SwingUtilities.getWindowAncestor(this);
   if (win != null) {
    dialog = new JDialog(win, "My Dialog",
         ModalityType.APPLICATION_MODAL);
    dialog.getContentPane().add(dialogPanel);
    dialog.pack();
    dialog.setLocationRelativeTo(null);
 dialog.setVisible(true); // here the modal dialog takes over
private JButton okButton = new JButton("OK");

代码示例来源:origin: cytoscape/application

private JDialog createDialog() {
  dialog = new JDialog(Cytoscape.getDesktop(), "Select Nodes By Name", false);
  JPanel main_panel = new JPanel();
  main_panel.setLayout(new BorderLayout());
  JLabel label = new JLabel("<HTML>Select nodes whose <B>name or synonym</B> is like <small>(use \"*\" and \"?\" for wildcards)</small></HTML>");
  main_panel.add(label, BorderLayout.NORTH);
  searchField = new JTextField(30);
  searchField.addActionListener(this);
  main_panel.add(searchField, BorderLayout.CENTER);
  JPanel button_panel = new JPanel();
  search = new JButton("Search");
  cancel = new JButton("Cancel");
  search.addActionListener(this);
  cancel.addActionListener(this);
  button_panel.add(search);
  button_panel.add(cancel);
  main_panel.add(button_panel, BorderLayout.SOUTH);
  dialog.setContentPane(main_panel);
  dialog.pack();
  return dialog;
}

代码示例来源:origin: stanfordnlp/CoreNLP

JButton cancel = new javax.swing.JButton();
JDialog dialog = new JDialog(new Frame(), "Parser Progress", true);
dialog.setVisible(true);

代码示例来源:origin: libgdx/libgdx

regionSelectDialog = new JDialog(editor, "Pick regions", true);
regionPickerPanel = new RegionPickerPanel(this);
JScrollPane scrollPane = new JScrollPane();
regionSelectDialog.setDefaultCloseOperation( JDialog.HIDE_ON_CLOSE);
addContent(0, 0, pickButton = new JButton("Pick Regions"), false, GridBagConstraints.WEST, GridBagConstraints.NONE);

代码示例来源:origin: org.netbeans.api/org-openide-util

dialog = new javax.swing.JDialog(parentDlg, title, true);
} else {
  dialog = new javax.swing.JDialog(frame, title, true);
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(chooser, BorderLayout.CENTER);

代码示例来源:origin: stackoverflow.com

final JDialog d = new JDialog();
d.setSize(200, 200);
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final int x = (screenSize.width - d.getWidth()) / 2;
final int y = (screenSize.height - d.getHeight()) / 2;
d.setLocation(x, y);
d.setVisible(true);

代码示例来源:origin: stackoverflow.com

import java.awt.event.*;
import javax.swing.*;

public class DialogListener {

  public static void main(String[] args) {
    JDialog dialog = new JDialog();
    dialog.setSize(300, 400);
    dialog.setVisible(true);

    KeyListener listener = getKeyListener();

    dialog.addKeyListener(listener);

    JTextArea area = new JTextArea();
    area.addKeyListener(listener);

    dialog.add(area);
  }

  public static KeyListener getKeyListener(){
    return new KeyAdapter() {
      public void keyTyped(KeyEvent e) {
        System.out.println(e.getKeyChar());
      }
    };

  }
}

代码示例来源:origin: stackoverflow.com

import javax.swing.*;

class TestDialogMinimize {

  public static void main(String[] args) {
    Runnable r = new Runnable() {
      public void run() {
        JFrame f = new JFrame("Has a Dialog");

        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(400,400);

        JDialog d = new JDialog(f);
        d.setSize(200,200);
        f.setVisible(true);
        d.setVisible(true);
      }
    };
    SwingUtilities.invokeLater(r);
  }
}

相关文章

JDialog类方法