Java Code Examples for javax.swing.JDialog

The following examples show how to use javax.swing.JDialog. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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);
}
 
Example 2
Source Project: marathonv5   Source File: JavaAgentTest.java    License: Apache License 2.0 6 votes vote down vote up
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();
        }
    });
}
 
Example 3
Source Project: triplea   Source File: HelpMenu.java    License: GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 4
Source Project: jdk8u_jdk   Source File: Test4177735.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 5
Source Project: jclic   Source File: Messages.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source Project: triplea   Source File: ChangePasswordPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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)));
}
 
Example 7
Source Project: SubTitleSearcher   Source File: ExtractDialog.java    License: Apache License 2.0 6 votes vote down vote up
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());

}
 
Example 8
Source Project: openjdk-8   Source File: Test4177735.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 9
Source Project: wandora   Source File: MashapeExtractorUI.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 10
Source Project: jdk8u-dev-jdk   Source File: Metalworks.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 11
Source Project: jdk8u-jdk   Source File: Metalworks.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 12
Source Project: netbeans   Source File: NotifyExceptionTest.java    License: Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 13
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();
                }
            }
        }
    });
}
 
Example 14
Source Project: gameserver   Source File: RedisRefreshService.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 15
Source Project: ghidra   Source File: DiffApplyIgnoreTest.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 16
Source Project: ghidra   Source File: DiffApplyIgnoreTest.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 17
Source Project: hottub   Source File: Test4177735.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example 18
Source Project: jdk8u60   Source File: WrongBackgroundColor.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
        }
    });
}
 
Example 19
Source Project: netbeans   Source File: NbErrorManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
public Dialog createDialog(DialogDescriptor descriptor) {
    lastDescriptor = descriptor;
    return new JDialog() {
        @SuppressWarnings("deprecation")
        @Override
        public void show() {}
    };
}
 
Example 20
Source Project: seaglass   Source File: SeaGlassTitlePane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 21
Source Project: sc2gears   Source File: FileBasedCache.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 );
}
 
Example 22
Source Project: gpx-animator   Source File: MarkdownDialog.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 23
Source Project: hottub   Source File: InputMethodPopupMenu.java    License: GNU General Public License v2.0 5 votes vote down vote up
static InputMethodPopupMenu getInstance(Component client, String title) {
    if ((client instanceof JFrame) ||
        (client instanceof JDialog)) {
            return new JInputMethodPopupMenu(title);
    } else {
        return new AWTInputMethodPopupMenu(title);
    }
}
 
Example 24
Source Project: jpexs-decompiler   Source File: View.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 25
Source Project: GpsPrune   Source File: ColourChooser.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 26
Source Project: osp   Source File: BrightnessFilter.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 27
Source Project: netbeans   Source File: SheetTable.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
}
 
Example 28
Source Project: binnavi   Source File: CColorChooser.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 29
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;
}
 
Example 30
/**
 * 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());
}