Results 1 to 5 of 5
Thread: CardLayout manager
- 03-26-2011, 11:02 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
CardLayout manager
I am stuck here people. How can I use the cardLayout manager to display different panels on the same frame depending on a menu selection? SOS
Java Code:[PHP]class BookStoreFrame extends JFrame { public BookStoreFrame() { setTitle("XX Book Store"); setPreferredSize(new Dimension(800, 400)); setResizable(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(new WelcomePanel()); this.pack(); centerWindow(this); JMenuBar menuBar = new JMenuBar(); // Add the menubar to the frame setJMenuBar(menuBar); //JMenuBar menuBar = new JMenuBar(); JMenu saleMenu = new JMenu("Sales"); JMenu returnMenu = new JMenu("Returns"); JMenu inventoryMenu = new JMenu("Inventory"); JMenu printMenu = new JMenu("Print"); menuBar.add(saleMenu); menuBar.add(returnMenu); menuBar.add(inventoryMenu); menuBar.add(printMenu); // Create and add simple menu item to one of the drop down menu JMenuItem saleAction = new JMenuItem("Make sales"); JMenuItem returnAction = new JMenuItem("Process Returns"); JMenuItem addNewBookAction = new JMenuItem("Add New Book"); JMenuItem checkInventoryAction = new JMenuItem("Availability"); JMenuItem printDailyAction = new JMenuItem("Print Daily Report"); saleMenu.add(saleAction); returnMenu.add(returnAction); inventoryMenu.add(addNewBookAction); inventoryMenu.add(checkInventoryAction); printMenu.add(printDailyAction); saleAction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //salesPanel } }); returnAction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //returnPanel } }); addNewBookAction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //inventoryPanel } }); checkInventoryAction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //inventoryPanel } }); printDailyAction.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //printPanel } }); } [/PHP]
- 03-26-2011, 11:26 PM #2
Senior Member
- Join Date
- Jan 2011
- Location
- Belgrade, Serbia
- Posts
- 227
- Rep Power
- 3
Could you please put corect tags.
- 03-27-2011, 12:10 AM #3
-
How is this different from the thread that you already have active on this question? Which thread should we address answers to? Please let's prevent needless splitting of a discussion.
- 03-27-2011, 01:46 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
Using a FlowLayout on top of a CardLayout
By snieuw in forum New To JavaReplies: 1Last Post: 11-08-2010, 06:03 PM -
Help with CardLayout
By Kyle227 in forum New To JavaReplies: 4Last Post: 05-28-2010, 01:03 AM -
cardlayout question
By newbie123 in forum New To JavaReplies: 1Last Post: 04-05-2010, 11:53 PM -
Regarding CardLayout
By adeeb in forum AWT / SwingReplies: 1Last Post: 06-07-2008, 07:52 PM -
Using previous with CardLayout
By uncopywritable in forum New To JavaReplies: 2Last Post: 08-05-2007, 09:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks