Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / How to make PopUp window in java

How to make PopUp window in java

August 19, 2021 by James Palmer

The same answer : JOptionpane with an example 🙂
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);
}
});
}
}

Hmm it has been a little while but from what I remember…
If you want a custom window you can just make a new frame and make it show up just like you would with the main window.
Java also has a great dialog library that you can check out here:
How to Make Dialogs
That may be able to give you the functionality you are looking for with a whole lot less effort.
Object[] possibilities = {“ham”, “spam”, “yam”};
String s = (String)JOptionPane.showInputDialog(
frame,
“Complete the sentence:n”
+ “”Green eggs and…””””

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in