9 Replies - 4842 Views - Last Post: 27 October 2012 - 04:56 PM Rate Topic: -----

#1 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Adding an image to a confirmation dialog box

Posted 27 October 2012 - 01:39 PM

Let me start off by saying that I'm completely new to Java programming. I started getting into it in August, when this semester started. Right now, we're on Chapter 4: Loops in the Intro to Java Programming book, if anyone's read that.

Now, my professor wants us to come up with a program package and present it to the class as if we were trying to sell some software for a specific purpose. My group and I decided we'd do programs that would be used in a bookstore, one of them being something like a most popular book search.

We have four genres we're going to use: Fiction, Non-Fiction, Sci Fi, and Novel. Here's an idea of how I'd like the program to run:

Dialog box (I might be using the wrong terminology here) pops up, asking the user which book they'd like to see, and a drop-down menu is available that will list the genres and their corresponding most popular books: "Which book would you like to see?"

After selecting a book from the drop down menu (and possibly confirming their choice?), another window will pop up (doesn't have to stack on top of the dialog box, can replace it, if that makes any difference) with an image of the book's cover and information about the author and when it was written, along with a confirmation (Yes/No/Cancel, although I'm hoping to customize what those buttons say) underneath it. If cancelled, the user can go back to selecting from the genres.

After a book is selected, another dialog box will come up saying "Thank you! Please bring this book to the checkout before you leave." with the picture of the book that was selected.

Firstly, is something like this far too advanced for someone of my standing? My second question is, what kind of resources should I be looking into to learn about how to do this? More specifically, what is it that I'm trying to do? What are the technical terms, so that I know what to search for to pull this off?

Thanks in advance, guys.

Is This A Good Question/Topic? 0
  • +

Replies To: Adding an image to a confirmation dialog box

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 01:50 PM

The static methos in JOptionPane:
http://docs.oracle.c...OptionPane.html
which are showConfirmDialog(), showInputDialog(), showMessageDialog() and showOptionDialog() are just nice an easy to use methods to simplify your life for quick messages exchange.
http://docs.oracle.c...nts/dialog.html
You can use an icon in them but if you want a full image you will have to write your on JDialog
http://docs.oracle.c...ng/JDialog.html
not using the simpler, already provided, feature of the OptionPane

Happy coding
Was This Post Helpful? 0
  • +
  • -

#3 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 01:57 PM

I kept up until you said "write your own JDialog." And I don't really understand much in that last link that you posted. :( But, now I think my biggest problem will be adding the images, and maybe being able to go back to the drop-down menu if the user selects "cancel" when they pick a book. Is that all explained in that last link? If so, can you point me in the right direction?
Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 02:02 PM

So can the image of the book be the size of an Icon or you need a bigger one ?

If youy are new to Java I think you will already enough to do. Start by using a standard JOptionPane, later on, if you still have time for your project, you can add the sherry over the sunday and make a very nice customized JDialog.
Was This Post Helpful? 0
  • +
  • -

#5 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 02:10 PM

I'd like it to be bigger. I don't really know what dimensions to use, but, just big enough to be seen clearly and small enough to not clutter the screen, you know what I mean?

We have until November 5th to get all of these programs done for the project. But, if I just do the program without the drop-down or images, it'll be rather simple-looking. That's why I wanted to do all the extra stuff, so it'll look good, and function well.
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 02:18 PM

So write you own class that extends JDialog
pass as parameters to the constructor th book info including the Image

Make the JDialog a GridLayout(1,2)
put the Image on the left side
find an appropriate layout for the right side depending on all the infor you have to display: title, author name, publisher, ....

The GridLayout will let the image take half the window.
Was This Post Helpful? 0
  • +
  • -

#7 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 02:22 PM

Sounds like it may be simple enough; where can I find out how to do that, in terms of what code to use?

And how will I link that to a drop-down menu? (For example, if someone picks Sci Fi in the drop-down menu in the FIRST dialog box, a picture will come up of whatever the most popular Sci Fi book is, and the options "I'll Take It!" and "Try Another" will come up. Does the "no" button count as cancel, where the user will be taken back to the drop-down menu? Or will I have to add a cancel button?)
Was This Post Helpful? 0
  • +
  • -

#8 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 02:28 PM

This is basic GUI components and concepts
You can add Listener to JComboBox
If you are new to Java it is an ambitious project to realize in 10 days
You can always start here
http://docs.oracle.c...torial/uiswing/

http://docs.oracle.c...s/combobox.html
Was This Post Helpful? 0
  • +
  • -

#9 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 04:45 PM

I'm gonna try to download the code for that combo box and run it to see how it works.

I still don't understand the link about swing packages, though. I only understand how to use jGrasp, which may or may not have something to do with that. :l
Was This Post Helpful? 0
  • +
  • -

#10 Shenaniganizer   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 35
  • Joined: 27-October 12

Re: Adding an image to a confirmation dialog box

Posted 27 October 2012 - 04:56 PM

I'm not really understanding how to create a combo box, either, now that I've looked at the source code.

Am I in over my head here? :dontgetit:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1