Solved

Java code to output details input by user not working

Posted on 2011-02-19
2
337 Views
Last Modified: 2012-08-14
Hi, Regarding the Java code below, I want to create a simple GUI that requests the title and author of a book and outputs something like "The title of the book is JAVA FOR DUMMIES and the author is T38" - what am I missing?  Thanks

import javax.swing.JOptionPane;

public class GUI {
      
      public static void main (String args[])
      
      {
            String title  = "";
            String author = "";
            
            title = JOptionPane.showInputDialog("Enter Title");
            
            author = JOptionPane.showInputDialog("Enter Author");
            
            JOptionPane.showMessageDialog(null, "The title of the book is :", "and the Author of the Book is : " Book Details",JOPtionPane.PLAIN_MESSAGE);
            
            System.exit(0);
      }
      

}
0
Comment
Question by:t38
2 Comments
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 34933678
Build your message string first.  I don't see where you are concatenating the message parts together.  I think you have messed up your commas, etc.  Also you misspelled JOptionPane.  Try this:
String message =  "The title of the book is :" + title +", and the Author of the Book is :" + author;

JOptionPane.showMessageDialog(null, message, "Book Details", JOptionPane.PLAIN_MESSAGE);

Open in new window

0
 

Author Closing Comment

by:t38
ID: 34933704
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 38
hibernate example for saving data 19 52
collection output issue 9 36
Eclipse for Java EE development 2 27
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question