473,548 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JOptionPane help

1 New Member
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.sho wInputDialog 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 javaapplication 1;

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

}

symbol : variable JOptionPane
location: class javaapplication 1.asg10
int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
1 error
BUILD FAILED (total time: 3 seconds)
Jul 4 '06 #1
2 3040
heat84
118 New Member
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.sho wInputDialog 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 javaapplication 1;

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

}

symbol : variable JOptionPane
location: class javaapplication 1.asg10
int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
1 error
BUILD FAILED (total time: 3 seconds)

The JOptionPane.sho wInputDialog 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 MVP
The JOptionPane.sho wInputDialog 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
12839
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 get something more like "Testing | tabs" (although it isn't a pipe symbol, it's something unusual).
1
4840
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 am able to prompt for typing the information but the display does not work. Here is my sample code: **
2
3336
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, however it is not working correctly. The message is not being painted to the screen properly and the whole screen becomes inactive and i cant press any...
2
2023
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 Number of upper/lower case e's in the (I)dialog box. Also have it repeat process until user enters Stop. Well yeah, thanks if anyone can help put that...
3
5049
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 sentence, using JOptionPane.showInputDialog(). 2. The program will scan each letter in the string and count how many times the upper case letter 'E'...
1
2115
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
1259
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
4530
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 necessary coz............in my game i cant afford having a JOptionPane tht looks sad .........I want to be catchy !!! kind regards, Malavika
3
7445
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 JDialog is not working. The code is running and not giving errors but when it comes to printing the statements, when I press enter , nothing is happening...
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7438
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.