Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

Using JOptionPane

Thread view: 
jazzy - 18 Apr 2004 19:35 GMT
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:

**

/**

* <p>TitleTesting</p>

* <p>Descriptio: Display Movie list</p>

*

*/

//Print Address Labels

import javax.swing.JOptionPane;

public class Homework1 {

 public Homework1() {

 }

 public static void main(String[] args) {

   String movieName;

   String theaterName;

 //Enter Movie Name

 String movieName =

     JOptionPane.showInputDialog(

     null, "Enter the Name of the Movie ",

     "Example 1.0 Input",

     JOptionPane.QUESTION_MESSAGE);

//Enter Name

String directorName=

    JOptionPane.showInputDialog(

    null, "Enter Name of Director ",

    "Example 1.1 Input",

    JOptionPane.QUESTION_MESSAGE);

//Display  Name of  Movie and Director

   String output =   movieName+ directorName

       JOptionPane.showMessageDialog(null,output,"Example 1.2 output",

                                JOptionPane.INFORMATION_MESSAGE);

 System.exit(0);

 }

}
Tom - 19 Apr 2004 14:59 GMT
> Hi,
>
[quoted text clipped - 67 lines]
>   }
> }

It would help to know what kind of errors you are getting.  Two things
that I noticed right away is that you have the variables movieName and
theaterName each declared twice.  You can do either of the following,
but not both.

String movieName;
movieName = JOptionPane.showInputDialog(blah, blah, blah);

OR

String movieName = JOptionPane.showInputDialog(blah, blah, blah);

I also don't see a need for the constructor, since you are not
instantiating your class.

I hope this helps.
tom
Karl von Laudermann - 19 Apr 2004 21:25 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> I am able to prompt for typing the information but the display does not
> work. Here is my sample code:

Your code as posted did not compile, because you're missing a
semicolon in one place, and movieName is declared twice. Once I fixed
these two errors, the code compiled and ran just fine. So I don't know
what problem you're having.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.