Solved

Java code to output details input by user not working

Posted on 2011-02-19
2
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

696 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