Answers for "java swing popup window"

1

java swing dialog box

JOptionPane.showMessageDialog(null, "java is fun");
Posted by: Guest on March-16-2020
0

Jframe popup window

package experiments;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class CreateDialogFromOptionPane {

    public static void main(final String[] args) {
        final JFrame parent = new JFrame();
        JButton button = new JButton();

        button.setText("Click me to show dialog!");
        parent.add(button);
        parent.pack();
        parent.setVisible(true);

        button.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                String name = JOptionPane.showInputDialog(parent,
                        "What is your name?", null);
            }
        });
    }
}
Posted by: Guest on January-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language