• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in JOptionPane.showInputDialog()  RSS feed

 
qhyang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have this problem when I try to use the showInputDialog() function of JOptionPane. I have one user interface, which contains "select", "delete", "update" buttons. When user clicks on the "delete" button, it pops up a JOptionPane to ask the user to input the last name. After getting the last name, the program will delete one record from the database.
Here are some of my code:
public void actionPerformed(ActionEvent evt) {
if(arg.equals("DELETE")) {
String BOX_TITLE="Confirmation Box";
String input = null;
input = (String)JOptionPane.showInputDialog(this, "Input the last name you want to delete", BOX_TITLE, JOptionPane.INFORMATION_MESSAGE, null, null, "Lastname");
System.out.println("User input last name is" + input);
..........
}
.....
}
When I click on the "Delete" button, it pops up the input dialog. I entered last name as "Yang" and then click OK. It gave me the following error message:

at java.awt.Component.processMouseEvent(Component.java:4992)
at java.awt.Container.processMouseEvent(Container.java:1383)
at java.awt.Component.dispatchEvent(Component.java:3501)
at java.awt.Container.dispatchEvent(Container.java:1440)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3195)
......
Any help would be appreciated. Thanks!
qhyang
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, qhyang is not a valid user name. Please re-register with a user name that follows the Official JavaRanch User Name Guidelines. Your user name is required to be in the format "First Name" + space + "Last Name".

As to your question, the actual problem is somewhere in the code that you have not provided... I can test out what you have posted and it works fine... Does the line "User input last name isyang" print out when you run this? The problem is later in the code...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!