1.

Solve : java JOptionPane?

Answer»

Hello guys,
I have started learning Java programming and as I learn I write some small programs to test what I have learned. I wrote a program that will open a small window and ask the user to INPUT a string of characters. Then the program counts the characters and displays the total number. It all works good.But this is my question, I would LIKE to improve the program so that it shows the count in a window instead of my IDE(I use Netbeans 6.5) .Below is the source code:

import javax.swing.JOptionPane;

public class WORDLENGTH {

public static VOID main ( String args[] ){

String name = JOptionPane.showInputDialog("What is the word?");
System.out.println(name);
int n = name.LENGTH();
System.out.printf("The length of the word is %d\n", n);
System.exit(0);
}
}

Thank you in advance!



Discussion

No Comment Found