473,388 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

JOptionPane help

1
Hey, I'm totally new to Java, and I'm taking a class. My current assignment involves inputting 2 names and corresponding bdays for each name using the JOptionPane.showInputDialog etc. Anyway, I'm confused by Sun's site and I keep getting error messages. Below is what I have and the error message when I try to compile. Any help would be much appreciated. Thanks!

package javaapplication1;

/**
*
* @author Jillian
*/
public class asg1 {
//This is a programme designed to output older or younger.
public static void main(String[] args) {
System.out.println("Author: Jillian);
int name1 = JOptionPane.showInputDialog("Input the first name:");
}

}

symbol : variable JOptionPane
location: class javaapplication1.asg10
int name1 = JOptionPane.showInputDialog("Input the first name:");
1 error
BUILD FAILED (total time: 3 seconds)
Jul 4 '06 #1
2 3035
heat84
118 100+
Hey, I'm totally new to Java, and I'm taking a class. My current assignment involves inputting 2 names and corresponding bdays for each name using the JOptionPane.showInputDialog etc. Anyway, I'm confused by Sun's site and I keep getting error messages. Below is what I have and the error message when I try to compile. Any help would be much appreciated. Thanks!

package javaapplication1;

/**
*
* @author Jillian
*/
public class asg1 {
//This is a programme designed to output older or younger.
public static void main(String[] args) {
System.out.println("Author: Jillian);
int name1 = JOptionPane.showInputDialog("Input the first name:");
}

}

symbol : variable JOptionPane
location: class javaapplication1.asg10
int name1 = JOptionPane.showInputDialog("Input the first name:");
1 error
BUILD FAILED (total time: 3 seconds)

The JOptionPane.showInputDialog method returns a string so instead of int name1 it should be String name one or alternatively you can parse the string and make the variable name1 an integer.
Nov 13 '07 #2
r035198x
13,262 8TB
The JOptionPane.showInputDialog method returns a string so instead of int name1 it should be String name one or alternatively you can parse the string and make the variable name1 an integer.
An even more worrying thing is that JOptionPane itself was never imported. It is in the javax.swing package.
Nov 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: - Steve - | last post by:
Example String testString = "Testing \t tabs"; JOptionPane.showMessageDialog(null, testString, "TEST", JOptionPane.INFORMATION_MESSAGE); Instead of getting the output "Testing tabs", I...
1
by: jazzy | last post by:
Hi, I am new to Java Programming and I am trying to write code using JOption pane to prompt user to type information and then have string output command to display information on the screen. I...
2
by: ragaman123 | last post by:
Hello there, I am designing a battleships game in java and am trying to output to the screen a simple message when a user sinks a ship. I have been trying to use JOptionPane to output a message,...
2
by: majorecono | last post by:
I took a look at the site and found this as a counter. Is there any way I can use it in a dialog box, that asks user to input any number of letters in a (?)dialog box, pressing enter and out comes...
3
by: majorecono | last post by:
What I'm bad at is the dialog box part. This is the code Ive come up with... if you see a way to improve what im thinkng of.... post it please. Program should.... 1. Ask user to type in a...
1
by: Smarteric | last post by:
import javax.swing.JOptionPane; public class MilesPerGallon { public static void main(String args) { String miles; String gallons; double MPG; double miles1, gallons1;
1
by: kamhal | last post by:
is there a way to use this function or any similar function in j#? i have been trying to figure out how to pop a message box in j#. can u help pls?
5
by: Ramola | last post by:
hi, I was wondering if i can customise a JOptionPane ??? ex : A JOptionPane by default has a background color gray............. can i change it ?? can i put some images in the background ? Its...
3
by: heat84 | last post by:
I want to customise JOptionPane and add a KeyListener to it. I want to behave in a certain manner when the enter key is pressed , but from the look of things, the key listener I am adding to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.