0

http://www.mathsisfun.com/games/memory/

Hello. I want to make a game like that. I am using windowbuilder. What should I use, japplet, jframe, jpanel? And all of those are square and I can put a few buttons. How will I make a game like the one in the link?

I will put a lot of buttons that will turn on when clicked. But jframe jpanel looks very small in area and I can not make exactly.

How will I start? Please help me, I am trying for days.

Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
john brown
  • 55
  • 1
  • 1
  • 5

1 Answers1

2

Use a nested layout1 in a panel. Put the panel in a frame.

For the nested layout, I suggest a GridLayout for the main area, and possibly a 1 column GridLayout or a BoxLayout for the buttons and controls on the right hand side.


What should i use, japplet, jframe, jpanel?

You seem to have some confusion.

  1. Avoid applets unless you are very experienced at making GUIs already, and absolutely need something that can be embedded in a web page. They are an absolute PITA.
  2. A frame is what (just about) every desktop app. needs.
  3. Panels can be put in applets, frames, dialogs, other panels.. They are a generic 'container' for holding other components. Ultimately they need to be displayed in a top level container such as a frame or applet.

Without panel, only frame is not enough?

It depends. If adding only one or few components, then a single layout in a frame will do. OTOH, if you really only have 1 component, show it in a JOptionPane (easier).

Few applications/frames will only have a couple of components though. Another thing to consider is that if a GUI is coded in a panel, that panel can then be displayed in a frame, or an applet (known as an 'hybrid application/applet'. ..Or it can be displayed in a window or a dialog or an option pane, or one side of a split pane, or one tab of a tabbed pane or in a list or..

In short, if it is in a panel, you immediately have many more options about how it can be used or reused.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • I will only use a frame inside a panel? That is all? Two different classes? – john brown Sep 21 '13 at 13:22
  • And why do i need a panel? Without panel, only frame is not enough? and if clicked a button, how will it turn into an image? – john brown Sep 21 '13 at 13:26
  • See the edit to answer for part of your answers, but *"..and if clicked a button, how will it turn into an image?"* note that SO is not a 'one stop fix my problem shop'. SO is designed as a Q&A site, with one (specific) question leading to one (specific) answer. I decided to answer the container oriented questions. You should ask a separate question (after searching, of course) if you cannot solve that quite different question. – Andrew Thompson Sep 21 '13 at 13:46