File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Adding java programs into JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding java programs into JFrame" Watch "Adding java programs into JFrame" New topic

Adding java programs into JFrame

bert ngo

Joined: Nov 20, 2008
Posts: 6
I need some help getting my last assignment finish and I am having a hard time finding help with this one. The goal of this last assignment is to take 6 program examples the professor has provided and put them into one top level container. I need some assistance being pointed into the right direction with this one.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
assuming the 6 prior examples are swing based:
ensure all 6 are built around a JPanel
create another JPanel set as a cardLayout
add the 6 examplePanels to the cardlayoutPanel
add the cardlayoutPanel to a JFrame
create a JMenu "Examples", with 6 JMenuItems "Example 1" to "Example 6"
add an actionListener to each menuItem, to show its respective panel
set the frame's menuBar

that's about it
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

or put each panel on a tab of a JTabbedPane.

GenRocket - Experts at Building Test Data
bert ngo

Joined: Nov 20, 2008
Posts: 6
I have read Michael Dunn's idea with the cardLayout into a JFrame and it's been going well so far. Thanks Michael in pointing me in the right direction and the java tutorials are helping work out the cardLayout.
wood burning stoves
subject: Adding java programs into JFrame
It's not a secret anymore!