Results 1 to 12 of 12
- 09-10-2010, 12:03 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 16
- Rep Power
- 0
Need help getting input(first/last name) from user
this is what i have but i need to also put in a last name and put it together in the "name" section.
import javax.swing.JOptionPane;
public class Assign2
{
public static void main(String[] args)
{
String name = JOptionPane.showInputDialog("Please enter your first name:");
JOptionPane.showMessageDialog(null, "Welcome, " + name + ", to CIS 226.");
}
}
- 09-10-2010, 12:06 AM #2
Why can't you replicate what you have there for the next part of the name you need?
-
-
Oh and also before I forget, welcome to the Java-Forums!
- 09-10-2010, 01:05 AM #5
Member
- Join Date
- Sep 2010
- Posts
- 16
- Rep Power
- 0
ohhh yeahhh. but how do i add them together?
- 09-10-2010, 01:08 AM #6
Member
- Join Date
- Sep 2010
- Posts
- 16
- Rep Power
- 0
I got it! haha it's something so easy.
But I have another question.
when the Joptionpanel comes up, and the user hits cancel, i want a certain message to pop up. how do i do that?
-
What do you see right now if they press cancel?
- 09-10-2010, 01:19 AM #8
Member
- Join Date
- Sep 2010
- Posts
- 16
- Rep Power
- 0
when i press cancel, it just skips and the final output is "hello ,null, null, "message"
-
- 09-10-2010, 01:42 AM #10
Member
- Join Date
- Sep 2010
- Posts
- 16
- Rep Power
- 0
My message dialog is showing up in a single line but i need to break it up into two lines.
I need it like this. how can i break it up?
Hello, Firstname + Lastname
Welcome to CIS 226.
JOptionPane.showMessageDialog(null, "Hello, " + firstname + " " + lastname + ", Welcome to CIS 226.");
- 09-11-2010, 02:40 AM #11
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
String and its method .split().... study.
-
Similar Threads
-
User Input
By brmcdani in forum New To JavaReplies: 2Last Post: 02-05-2010, 01:59 AM -
how to get input from User
By Alvaro in forum New To JavaReplies: 7Last Post: 01-15-2010, 11:02 PM -
user input with JTextArea
By andre1011 in forum Advanced JavaReplies: 6Last Post: 04-16-2009, 04:09 AM -
User input- Pop Up Box
By dedachi in forum AWT / SwingReplies: 3Last Post: 03-23-2009, 04:47 AM -
cant take input from user
By new_1 in forum New To JavaReplies: 6Last Post: 12-25-2007, 07:38 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks