类javax.swing.JDialog源码实例Demo

下面列出了怎么用javax.swing.JDialog的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Zettelkasten   文件: TestExportToTexTask.java
@Before
public void initialize() throws Exception {
	settings = TestObjectFactory.ZKN3Settings.ZKN3_TRICKY_MARKDOWN;
	daten = TestObjectFactory.getDaten(settings);

	JDialog parent = null;
	Application app = org.jdesktop.application.Application
			.getInstance(ZettelkastenApp.class);
	JLabel label = new JLabel();
	TasksData td = null;
	DesktopData dt = null;
	File fp = null;
	BibTex bto = null;
	ArrayList<Object> ee = null;
	int type = 0;
	int part = 0;
	DefaultMutableTreeNode n = null;
	boolean bibtex = false;
	boolean ihv = false;
	boolean numberprefix = false;
	boolean contenttable = false;

	exportToTexTask = new ExportToTexTask(app, parent, label, td, daten,
			dt, settings.settings, bto, fp, ee, type, part, n, bibtex, ihv,
			numberprefix, contenttable, false);
}
 
源代码2 项目: marathonv5   文件: JavaAgentTest.java
public void switchTo() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            d2 = new JDialog(frame, false);
            d2.setName("dialog-2");
            d2.setTitle("My Dialog 2");
            JButton b = new JButton("Click-Me-2");
            b.setName("click-me-2");
            d2.getContentPane().add(b);
            d2.pack();
            d2.setVisible(true);
        }
    });
    Collection<String> windowHandles = driver.getWindowHandles();
    AssertJUnit.assertEquals(2, windowHandles.size());
    driver.switchTo().window("dialog-2");
    AssertJUnit.assertNotNull(driver.findElementByName("click-me-2"));
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            d2.dispose();
        }
    });
}
 
源代码3 项目: 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;
}
 
源代码4 项目: jdk8u_jdk   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码5 项目: jclic   文件: Messages.java
public static boolean showDlg(final JDialog dialog) {
  if (SwingUtilities.isEventDispatchThread()) {
    dialog.setVisible(true);
  } else {
    try {
      SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
          dialog.setVisible(true);
        }
      });
    } catch (Exception ex) {
      System.err.println("Show dialog error: " + ex);
      return false;
    }
  }
  return true;
}
 
源代码6 项目: triplea   文件: ChangePasswordPanel.java
/**
 * Shows this panel in a modal dialog.
 *
 * @param parent The dialog parent window.
 * @return New password entered by user, otherwise null if the window is closed.
 */
private Optional<String> show(final Window parent) {
  dialog = new JDialog(JOptionPane.getFrameForComponent(parent), "", true);
  dialog.getContentPane().add(this);
  SwingKeyBinding.addKeyBinding(this, KeyCode.ESCAPE, this::close);
  dialog.pack();
  dialog.setLocationRelativeTo(parent);
  dialog.setVisible(true);
  dialog.dispose();
  dialog = null;
  if (!validatePasswordsAndUpdateValidationText()) {
    return Optional.empty();
  }

  final char[] password = passwordField.getPassword();
  if (rememberPassword.isSelected()) {
    ClientSetting.lobbySavedPassword.setValueAndFlush(password);
  } else {
    ClientSetting.lobbySavedPassword.resetValue();
  }
  return Optional.of(Sha512Hasher.hashPasswordWithSalt(String.valueOf(password)));
}
 
源代码7 项目: SubTitleSearcher   文件: ExtractDialog.java
private void initComponents() {
	ExtractDialog _this = this;
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	// setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	setIconImage(MainWin.icon);
	setSize(820, 460);
	// setResizable(false);

	setLocationRelativeTo(this.getParent());
	setTitle("请选择压缩包中要保存的字幕文件");

	this.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			_this.clear();
			_this.dispose();
		}
	});

	add(bsPanel, BorderLayout.CENTER);
	openUrl(MainWin.class.getResource("/html/extract_dialog.html").toExternalForm());

}
 
源代码8 项目: openjdk-8   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码9 项目: wandora   文件: MashapeExtractorUI.java
public void open(Wandora w, Context c) {
    context = c;
    wandora = w;
    accepted = false;
    dialog = new JDialog(w, true);
    dialog.setSize(550, 500);
    dialog.add(this);
    dialog.setTitle("Mashape API extractor");
    UIBox.centerWindow(dialog, w);
    if(apikey != null){
        forgetButton.setEnabled(true);
    } else {
        forgetButton.setEnabled(false);
    }
    dialog.setVisible(true);
}
 
源代码10 项目: jdk8u-dev-jdk   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码11 项目: jdk8u-jdk   文件: Metalworks.java
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
 
源代码12 项目: netbeans   文件: NotifyExceptionTest.java
public void testYesDialogShown() throws Exception {
    Frame mainWindow = WindowManager.getDefault().getMainWindow();
    final JDialog modalDialog = new HiddenDialog( mainWindow, true );
    DD.toReturn = modalDialog;

    Logger l = Logger.getLogger(getName());
    l.setLevel(Level.ALL);
    System.setProperty("netbeans.exception.report.min.level", "200");
    l.log(Level.CONFIG, "Something is wrong", new NullPointerException("npe"));
    waitEQ();
    assertNotNull("Really returned", DD.lastDescriptor);
    assertEquals("It is DialogDescriptor", DialogDescriptor.class, DD.lastDescriptor.getClass());
    DialogDescriptor dd = (DialogDescriptor)DD.lastDescriptor;
    assertFalse( "The request is for non-modal dialog", dd.isModal());
    assertFalse("Main window is not visible", mainWindow.isVisible());
}
 
源代码13 项目: wildfly-core   文件: BrowseButton.java
public BrowseButton(final JDialog parentDialog, final JTextField targetField) {
    super("Browse ...");
    addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            int returnVal = fileChooser.showOpenDialog(parentDialog);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    targetField.setText(fileChooser.getSelectedFile().getCanonicalPath());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
源代码14 项目: gameserver   文件: RedisRefreshService.java
public RedisRefreshService(RedisTreeTableModel treeTableModel, String host, int port) {
	this.treeTableModel = treeTableModel;
	this.host = host;
	this.port = port;
	
	panel = new JXPanel();
	panel.setLayout(new MigLayout("wrap 1"));
	panel.add(label, "growx, wrap 20");
	panel.add(progressBar, "grow, push");

	dialog = new JDialog();
	dialog.add(panel);
	dialog.setSize(300, 120);
	Point p = WindowUtils.getPointForCentering(dialog);
	dialog.setLocation(p);
	dialog.setModal(true);
	dialog.setResizable(false);
	dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
}
 
源代码15 项目: ghidra   文件: DiffApplyIgnoreTest.java
@Test
public void testCodeUnitIgnore() throws Exception {
	openDiff(diffTestP1, diffTestP2);
	JDialog dialog = waitForJDialog(tool.getToolFrame(), "Memory Differs", 2000);
	assertNotNull(dialog);
	pressButtonByText(dialog, "OK");
	waitForPostedSwingRunnables();
	showApplySettings();

	ProgramSelection origDiffs = diffPlugin.getDiffHighlightSelection();
	ignore(codeUnitApplyCB);
	AddressSet as = new AddressSet(addr("10024b8"), addr("10024b8"));
	setDiffSelection(as);
	apply();
	assertEquals(origDiffs, diffPlugin.getDiffHighlightSelection());
}
 
源代码16 项目: ghidra   文件: DiffApplyIgnoreTest.java
@Test
public void testPropertyIgnore() throws Exception {
	openDiff(diffTestP1, diffTestP2);
	JDialog dialog = waitForJDialog(tool.getToolFrame(), "Memory Differs", 2000);
	assertNotNull(dialog);
	pressButtonByText(dialog, "OK");
	waitForPostedSwingRunnables();
	showApplySettings();

	ProgramSelection origDiffs = diffPlugin.getDiffHighlightSelection();
	ignore(propertiesApplyCB);
	AddressSet as = new AddressSet(addr("100248c"), addr("100248e"));
	setDiffSelection(as);
	apply();
	assertEquals(origDiffs, diffPlugin.getDiffHighlightSelection());
}
 
源代码17 项目: hottub   文件: Test4177735.java
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
源代码18 项目: jdk8u60   文件: WrongBackgroundColor.java
public static void main(final String[] args)
        throws InvocationTargetException, InterruptedException {
    SwingUtilities.invokeAndWait(() -> {
        UIDefaults ui = UIManager.getDefaults();
        ui.put("control", new ColorUIResource(54, 54, 54));
        final JDialog dialog = new JDialog();
        final JFrame frame = new JFrame();
        frame.pack();
        dialog.pack();
        final Color dialogBackground = dialog.getBackground();
        final Color frameBackground = frame.getBackground();
        frame.dispose();
        dialog.dispose();
        if (!dialogBackground.equals(frameBackground)) {
            System.err.println("Expected:" + frameBackground);
            System.err.println("Actual:" + dialogBackground);
            throw new RuntimeException("Wrong background color");
        }
    });
}
 
源代码19 项目: netbeans   文件: NbErrorManagerTest.java
public Dialog createDialog(DialogDescriptor descriptor) {
    lastDescriptor = descriptor;
    return new JDialog() {
        @SuppressWarnings("deprecation")
        @Override
        public void show() {}
    };
}
 
源代码20 项目: seaglass   文件: SeaGlassTitlePane.java
/**
 * Add a property change listener to the root pane.
 *
 * @param listener the propertiy change listener to add.
 */
private void addParentPropertyChangeListener(PropertyChangeListener listener) {
    if (rootParent instanceof JFrame) {
        ((JFrame) rootParent).addPropertyChangeListener(listener);
    } else if (rootParent instanceof JDialog) {
        ((JDialog) rootParent).addPropertyChangeListener(listener);
    }

    rootPane.addPropertyChangeListener(listener);
}
 
源代码21 项目: sc2gears   文件: FileBasedCache.java
/**
 * Empties the cache: deletes all files in the cache.<br>
 * Displays a modal info dialog about the fact that the cache is being emptied.
 * @param owner optional owner of the info dialog
 */
protected static void emptyCache_( final String cacheEntity, final Dialog owner, final String infoTextKey, final String cacheFolder ) {
	System.out.println( "Clearing " + cacheEntity + " cache..." );
	
	final JDialog infoDialog = owner == null ? new JDialog() : new JDialog( owner );
	infoDialog.setModal( true );
	infoDialog.setTitle( Language.getText( "general.infoTitle" ) );
	final JLabel infoLabel = new JLabel( Language.getText( infoTextKey ) );
	infoLabel.setFont( infoLabel.getFont().deriveFont( Font.ITALIC ) );
	infoLabel.setBorder( BorderFactory.createEmptyBorder( 25, 35, 25, 35 ) );
	infoDialog.getContentPane().add( infoLabel );
	infoDialog.pack();
	if ( owner == null )
		infoDialog.setLocationRelativeTo( null );
	else
		GuiUtils.centerWindowToWindow( infoDialog, owner );
	
	new NormalThread( cacheEntity + " cache emptier" ) {
		@Override
		public void run() {
			final File[] cacheFiles = new File( cacheFolder ).listFiles();
			if ( cacheFiles != null )
				for ( final File cacheFile : cacheFiles )
					deleteFile( cacheFile );
			
			infoDialog.dispose();
		}
	}.start();
	
	infoDialog.setVisible( true );
}
 
源代码22 项目: gpx-animator   文件: MarkdownDialog.java
public MarkdownDialog(final JFrame owner, final String title,
                      @NonNls final String filename,
                      final Map<String, String> variables,
                      final int width, final int height) {
    super(owner, true);
    this.filename = filename;
    this.variables = variables;
    setTitle(title);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setContentPane(buildContent());
    setSize(width, height);
    setLocationRelativeTo(owner);
    setVisible(true);
}
 
源代码23 项目: hottub   文件: InputMethodPopupMenu.java
static InputMethodPopupMenu getInstance(Component client, String title) {
    if ((client instanceof JFrame) ||
        (client instanceof JDialog)) {
            return new JInputMethodPopupMenu(title);
    } else {
        return new AWTInputMethodPopupMenu(title);
    }
}
 
源代码24 项目: jpexs-decompiler   文件: View.java
public static void installEscapeCloseOperation(final JDialog dialog) {
    Action dispatchClosing = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent event) {
            dialog.dispatchEvent(new WindowEvent(
                    dialog, WindowEvent.WINDOW_CLOSING));
        }
    };
    JRootPane root = dialog.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
            escapeStroke, dispatchWindowClosingActionMapKey);
    root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing);
}
 
源代码25 项目: GpsPrune   文件: ColourChooser.java
/**
 * Constructor
 * @param inParent parent dialog
 */
public ColourChooser(JDialog inParent)
{
	_dialog = new JDialog(inParent, I18nManager.getText("dialog.colourchooser.title"), true);
	_dialog.setLocationRelativeTo(inParent);
	_dialog.getContentPane().add(makeContents());
	_dialog.pack();
}
 
源代码26 项目: osp   文件: BrightnessFilter.java
/**
 * Implements abstract Filter method.
 *
 * @return the inspector
 */
public synchronized JDialog getInspector() {
	Inspector myInspector = inspector;
  if (myInspector==null) {
  	myInspector = new Inspector();
  }
  if (myInspector.isModal() && vidPanel!=null) {
    frame = JOptionPane.getFrameForComponent(vidPanel);
    myInspector.dispose();
    myInspector = new Inspector();
  }
  inspector = myInspector;
  inspector.initialize();
  return inspector;
}
 
源代码27 项目: netbeans   文件: SheetTable.java
/** Returns the content pane of our owner, so as to display the wait
 * cursor while the dialog is being invoked */
@Override
public Component getCursorChangeComponent() {
    Container cont = SheetTable.this.getTopLevelAncestor();

    return (cont instanceof JFrame) ? ((JFrame) cont).getContentPane()
                                    : ((cont instanceof JDialog) ? ((JDialog) cont).getContentPane() : cont);
}
 
源代码28 项目: binnavi   文件: CColorChooser.java
public static JDialog createDialog(final Component parent, final String title,
    final boolean modal, final CColorChooser chooserPane, final ActionListener okListener,
    final ActionListener cancelListener) throws HeadlessException {
  // Just forward to ancestor
  return JColorChooser
      .createDialog(parent, title, modal, chooserPane, okListener, cancelListener);
}
 
源代码29 项目: wandora   文件: AddSubjectIdentifierPanel.java
public String open(Wandora wandora, String label, String title) {
    wasAccepted = false;
    this.wandora = wandora;
    dialog = new JDialog(wandora, true);
    
    dialog.setTitle(title);
    locatorLabel.setText(label);
    dialog.add(this);
    dialog.setSize(500, 170);
    wandora.centerWindow(dialog);
    dialog.setVisible(true);
    
    if(wasAccepted) return locatorField.getText();
    else return null;
}
 
源代码30 项目: jdk8u-dev-jdk   文件: WindowClosedEventOnDispose.java
/**
 * Test if a dialog that has never been shown fire
 * the WINDOW_CLOSED event on parent dispose().
 * @throws Exception
 */
public static void testHidenChildDispose() throws Exception {
    JFrame f = new JFrame();
    JDialog dlg = new JDialog(f);
    Listener l = new Listener();
    dlg.addWindowListener(l);
    f.dispose();
    waitEvents();

    assertEquals(0, l.getCount());
}
 
 类所在包
 同包方法