javax.swing.JDialog#add ( )源码实例Demo

下面列出了javax.swing.JDialog#add ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: triplea   文件: HelpMenu.java
private static JDialog createInformationDialog(final JComponent component, final String title) {
  final JDialog dialog = new JDialog((JFrame) null, title);
  dialog.add(component, BorderLayout.CENTER);
  final JPanel buttons = new JPanel();
  final JButton button =
      new JButton(
          SwingAction.of(
              "OK",
              event -> {
                dialog.setVisible(false);
                dialog.removeAll();
                dialog.dispose();
              }));
  buttons.add(button);
  dialog.getRootPane().setDefaultButton(button);
  dialog.add(buttons, BorderLayout.SOUTH);
  dialog.pack();
  dialog.addWindowListener(
      new WindowAdapter() {
        @Override
        public void windowOpened(final WindowEvent e) {
          button.requestFocus();
        }
      });
  return dialog;
}
 
源代码2 项目: freeinternals   文件: UITool.java
/**
 * Show a popup window with given message.
 *
 * @param frame Parent window
 * @param panel Content in panel
 * @param title Popup window title
 */
public static void showPopup(final JFrame frame, final JPanel panel, final String title) {
    if (frame == null || panel == null) {
        return;
    }

    final JDialog popup = new JDialog(frame, title);
    popup.setSize(
            (int) Math.floor(frame.getWidth() * POPUP_RATIO),
            (int) Math.floor(frame.getHeight() * POPUP_RATIO));
    popup.setLayout(new BorderLayout());
    popup.add(panel, BorderLayout.CENTER);
    popup.setLocationRelativeTo(frame);
    popup.setVisible(true);
}
 
源代码3 项目: wandora   文件: SimilarityMatrixExportDialog.java
public void open() {
    myDialog = new JDialog(Wandora.getWandora(), true);
    myDialog.add(this);
    myDialog.setSize(600,320);
    myDialog.setTitle("Similarity matrix export options");
    UIBox.centerWindow(myDialog, Wandora.getWandora());
    wasAccepted = false;
    myDialog.setVisible(true);
}
 
源代码4 项目: CodenameOne   文件: AddThemeEntry.java
private void customizeBorderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customizeBorderActionPerformed
    BorderEditor editor = new BorderEditor(currentBorder, resources);
    JDialog dialog = new JDialog((JDialog)SwingUtilities.windowForComponent(this), "Border");
    dialog.setLayout(new BorderLayout());
    dialog.add(BorderLayout.CENTER, editor);
    dialog.pack();
    dialog.setLocationRelativeTo(customizeBorder);
    dialog.setModal(true);
    dialog.setVisible(true);
    currentBorder = editor.getResult();
    updateThemePreview();
}
 
public void openInDialog(Wandora wandora) {
    setLanguages();

    accepted = false;

    dialog = new JDialog(wandora, true);
    dialog.setSize(500,350);
    dialog.setTitle("Select translation languages");
    wandora.centerWindow(dialog);
    dialog.add(this);
    dialog.setVisible(true);
}
 
源代码6 项目: hortonmachine   文件: GeopaparazziViewer.java
private void openImageInDialog( long imageId, String imageName, File dbFile, boolean doOriginalSize ) throws Exception {
    BufferedImage bufferedImage = readImageToBufferedImage(imageId, dbFile, doOriginalSize);

    if (bufferedImage != null) {
        JDialog f = new JDialog();
        f.add(new JLabel(new ImageIcon(bufferedImage)), BorderLayout.CENTER);
        f.setTitle(imageName);
        f.pack();
        f.setSize(bufferedImage.getWidth(), bufferedImage.getHeight());
        f.setLocationRelativeTo(null); // Center on screen
        f.setVisible(true);
        f.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    }
}
 
源代码7 项目: jdk8u-jdk   文件: ImageableAreaTest.java
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
public void openInDialog(Wandora wandora) {
    someLangs = filterLangs(wandora.getTopicMap(), langs);
    setLanguages();

    accepted = false;

    dialog = new JDialog(wandora, true);
    dialog.setSize(500,470);
    dialog.setTitle("Select source and target languages");
    wandora.centerWindow(dialog);
    dialog.add(this);
    dialog.setVisible(true);
}
 
源代码9 项目: lucene-solr   文件: AboutDialogFactory.java
@Override
public JDialog create(Window owner, String title, int width, int height) {
  dialog = new JDialog(owner, title, Dialog.ModalityType.APPLICATION_MODAL);
  dialog.add(content());
  dialog.setSize(new Dimension(width, height));
  dialog.setLocationRelativeTo(owner);
  dialog.getContentPane().setBackground(prefs.getColorTheme().getBackgroundColor());
  return dialog;
}
 
源代码10 项目: TencentKona-8   文件: ImageableAreaTest.java
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码11 项目: wandora   文件: SQLExtractorUI.java
public void open(Wandora w) {
    accepted = false;
    dialog = new JDialog(w, true);
    dialog.setSize(750,400);
    dialog.add(this);
    dialog.setTitle("SQL Extractor");
    UIBox.centerWindow(dialog, w);
    dialog.setVisible(true);
}
 
源代码12 项目: wandora   文件: RTopicPanel.java
private void openOptionsDialog() {
    optionsDialog = new JDialog(Wandora.getWandora(), true);
    optionsDialog.setSize(500,270);
    optionsDialog.add(optionsPanel);
    optionsDialog.setTitle("R topic panel options");
    Wandora.getWandora().centerWindow(optionsDialog);
    optionsDialog.setVisible(true);
}
 
源代码13 项目: wandora   文件: FBGraphExtractorPanel.java
void open() {
    app = Wandora.getWandora();
    window = new JDialog(app, AbstractFBGraphExtractor.NAME, true);
    window.add(this);
    window.setSize(DIMENSION);
    app.centerWindow(window);
    window.setVisible(true);
}
 
源代码14 项目: aion-germany   文件: InflateReader.java
public void actionPerformed(ActionEvent e) {
	JDialog dlg = new JDialog(((Main) PacketSamurai.getUserInterface()).getMainFrame(), "Text");
	dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	dlg.setSize(350, 400);
	dlg.setLocationRelativeTo(((Main) PacketSamurai.getUserInterface()).getMainFrame());

	JEditorPane sourceDisplay = new JEditorPane();
	sourceDisplay.setEditable(false);
	sourceDisplay.setContentType("text/plain");
	sourceDisplay.setText(_xml);

	dlg.add(new JScrollPane(sourceDisplay));
	dlg.setVisible(true);
}
 
源代码15 项目: pgptool   文件: AboutView.java
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.aboutApp"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	return ret;
}
 
源代码16 项目: lucene-solr   文件: OptimizeIndexDialogFactory.java
@Override
public JDialog create(Window owner, String title, int width, int height) {
  dialog = new JDialog(owner, title, Dialog.ModalityType.APPLICATION_MODAL);
  dialog.add(content());
  dialog.setSize(new Dimension(width, height));
  dialog.setLocationRelativeTo(owner);
  dialog.getContentPane().setBackground(prefs.getColorTheme().getBackgroundColor());
  return dialog;
}
 
源代码17 项目: opt4j   文件: DefaultAbout.java
@Override
public JDialog getDialog(ApplicationFrame frame) {
	JDialog dialog = new JDialog(frame, "About Configurator", true);
	dialog.setBackground(Color.WHITE);
	dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	dialog.setResizable(false);

	dialog.add(new JLabel("Void Frame"));
	dialog.pack();
	dialog.setVisible(false);

	return dialog;
}
 
源代码18 项目: lucene-solr   文件: EditParamsDialogFactory.java
@Override
public JDialog create(Window owner, String title, int width, int height) {
  dialog = new JDialog(owner, title, Dialog.ModalityType.APPLICATION_MODAL);
  dialog.add(content());
  dialog.setSize(new Dimension(width, height));
  dialog.setLocationRelativeTo(owner);
  dialog.getContentPane().setBackground(prefs.getColorTheme().getBackgroundColor());
  return dialog;
}
 
源代码19 项目: openjdk-jdk9   文件: ServiceDlgSheetCollateTest.java
private static void doTest(Runnable action) {
    String description
            = " A print dialog would appear.\n"
            + " Increase the no. of copies.\n"
            + " If COLLATE checkbox gets enabled, press FAIL else press PASS.\n"
            + " Press Cancel to close the dialog.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码20 项目: jdk8u_jdk   文件: DlgAttrsBug.java
private static void doTest(Runnable action) {
    String description
            = " Visual inspection of print dialog is required.\n"
            + " A print dialog will be shown.\n "
            + " Please verify Copies 5 is selected.\n"
            + " Also verify, Page Range is selected with "
            + " from page 3 and to Page 4.\n"
            + " If ok, press PASS else press FAIL";

    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}