Java 8 Dialog - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Dialog class.

This code example shows how to use the following methods:show, getDirectory, getFile, setMode
import java.awt.FileDialog;
public class SobelFilterDemo { 
 
	static File chooseFile() {
		if (Platform.isMac()) { 
			FileDialog d = new FileDialog((java.awt.Frame)null);
			d.setMode(FileDialog.LOAD);
			d.show();
			String f = d.getFile();
			if (f != null)
				return new File(new File(d.getDirectory()), d.getFile());
		} else { 
	        JFileChooser chooser = new JFileChooser();
	        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
	        	return chooser.getSelectedFile();
		} 
        return null; 
	} 
     public static void main(String[] args) {
        try { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, pack, setLocationRelativeTo, setContentPane, setDefaultCloseOperation
        final JOptionPane optionPane = new JOptionPane(
                params, 
                JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION);
 
        final JDialog dialog = new JDialog(getMainFrame(), "Confirmation of licenses and agreements", true);
        dialog.setContentPane(optionPane);
        dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        optionPane.addPropertyChangeListener(
                new PropertyChangeListener() {
                    @Override 
                    public void propertyChange(PropertyChangeEvent e) {
                        String prop = e.getPropertyName();
 
                        if (dialog.isVisible()
                                && (e.getSource() == optionPane)
                                && (JOptionPane.VALUE_PROPERTY.equals(prop))) {
                            dialog.setVisible(false);
                        } 
                    } 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, setSize, getContentPane
    public static void execLoop(JComponent editor, Frame parent, boolean modal) {
        execLoop(editor, parent, modal, 800, 600);
    } 
 
    public static void execLoop(JComponent editor, Frame parent, boolean modal, int w, int h) {
        JDialog dialog = new JDialog(parent, modal);
 
        Container contentPane = dialog.getContentPane();
        contentPane.setLayout(new BorderLayout());
 
        JScrollPane scrollPane = new JScrollPane(editor);
        contentPane.add(scrollPane, BorderLayout.CENTER);
 
        dialog.setSize(w, h);
        centerWindow(dialog);
        dialog.setVisible(true);
 
    } 
 
    public static void execLoop(JComponent editor, boolean modal) {
        execLoop(editor, new JFrame(), modal);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, getDirectory, getFile
File file = null;
 
			if(args.length == 0)
			{ 
				FileDialog dialog = new FileDialog(new Frame(), "Select file...", FileDialog.LOAD);
				dialog.setVisible(true);
 
				String d = dialog.getDirectory();
				String f = dialog.getFile();
 
				if(d != null && f != null)
				{ 
					args = new String[] { d + f };
				} 
				else 
				{ 
					System.out.println("No file selected... Bye!");
					System.exit(0);
				} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setTitle, pack, getContentPane
     * Create a new ForceConfigAction. 
     * @param frame the parent frame for which to create the dialog 
     * @param fsim the force simulator to configure 
     */ 
    public ForceConfigAction(JFrame frame, ForceSimulator fsim) {
        dialog = new JDialog(frame, false);
        dialog.setTitle("Configure Force Simulator");
        JPanel forcePanel = new JForcePanel(fsim);
        dialog.getContentPane().add(forcePanel);
        dialog.pack();
    } 
     
    /** 
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 
     */ 
    public void actionPerformed(ActionEvent e) {
        dialog.setVisible(true);
    } 
 
} // end of class ForceConfigAction 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, getContentPane
     * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent) 
     */ 
    @Override 
    public void doAction(ActionEvent e) {
        if (helpWindow == null) {
            helpWindow = new JDialog(new Frame(),// independent frame to
                                                    // allow it to be overlaid 
                                                    // by the main frame 
                    JMeterUtils.getResString("help"),//$NON-NLS-1$ 
                    false); 
            helpWindow.getContentPane().setLayout(new GridLayout(1, 1));
            ComponentUtil.centerComponentInWindow(helpWindow, 60);
        } 
        helpWindow.getContentPane().removeAll();
        helpWindow.getContentPane().add(scroller);
        helpWindow.setVisible(true);
        if (e.getSource() instanceof String[]) {
            String[] source = (String[]) e.getSource();
            resetPage(source[0]);
            helpDoc.scrollToReference(source[1]);
        } else { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:show, getDirectory, getFile, setFile
    * Save the jMusic score as a standard MIDI file 
    * Prompt user for a filename 
    * @param Score 
    */  
    public static void midi(Score score) {
        FileDialog fd = new FileDialog(new Frame(), 
                                       "Save as a MIDI file ...",  
                                       FileDialog.SAVE);
        fd.setFile("jMusic_composition.mid");
        fd.show();
        if (fd.getFile() != null) {
            Write.midi(score, fd.getDirectory() + fd.getFile());                
        } 
         
    } 
     
    /** 
     * Write the score to outputStream as a standard MIDI file 
     * @param Score 
     * @param OutputStream outputStream 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, getDirectory, getFile
    } 
 
    public static void saveToFile(final String saveDialogTitle, final String title, final String text) {
        final Frame parent = new Frame();
 
        final FileDialog dialog = new FileDialog(parent, saveDialogTitle, FileDialog.SAVE);
        dialog.setVisible(true);
        final String file = dialog.getFile();
        final String dir = dialog.getDirectory();
 
        parent.dispose();
 
        saveToFile(new File(dir, file), title, text);
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setVisible, setLocation, setSize
        dialog.setLayout(new BorderLayout());
        dialog.add(glCanvas1, BorderLayout.CENTER);
 
        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
            public void run() { 
                dialog.setLocation(200, 200);
                dialog.setSize(width/2, height/2);
                dialog.setVisible(true);
            }}); 
        Assert.assertEquals(true,  AWTRobotUtil.waitForVisible(dialog, true));
        Assert.assertEquals(true,  AWTRobotUtil.waitForRealized(glCanvas1, true));
 
        animator.start();
        Assert.assertTrue(animator.isStarted());
        Assert.assertTrue(animator.isAnimating());
        animator.setUpdateFPSFrames(60, System.err);
 
        final long t0 = System.currentTimeMillis();
        long t1 = t0;
        while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParent, getSize, setBounds
     * @param verticalPercent  the relative location. 
     */ 
    public static void positionDialogRelativeToParent(final Dialog dialog,
                                                      final double horizontalPercent,
                                                      final double verticalPercent) {
      final Container parent = dialog.getParent();
      if (parent == null)
      { 
        centerFrameOnScreen(dialog);
        return; 
      } 
 
      final Dimension d = dialog.getSize();
      final Dimension p = parent.getSize();
 
      final int baseX = parent.getX();
      final int baseY = parent.getY();
 
      final int x = baseX + (int) (horizontalPercent * p.width);
      final int y = baseY + (int) (verticalPercent * p.height);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 Dialog Methods: