View Full Version : JAVA - JTabbedPane Help [pic]
March 7th, 2007, 03:44 PM
Got a little java problem, cant seem to figure it out.
I wanna point a JMenuItem to one of the tabs, so when i click the MenuItem the tab is selected.
March 7th, 2007, 03:48 PM
Look into the Model-View-Controller (MVC) GUI design strategy. Selecting a menu item will trigger an event processed by the controller which updates the model, and the view renders the updated model.
March 7th, 2007, 04:03 PM
Add an ActionListener to JMenuItem(It is a type of button after all) ... when clicked do a requestFocus() on the component in the Tab...
March 7th, 2007, 04:08 PM
Thx for reply
int sel = tabbs.getSelectedIndex() + 3;
which did what i wanted it to do, when i click it 'New Customer' is selected'. But its not pointing at that tab, its pointing at tab number 4 (0,1,2,3), so if there were more tabs it would move on to tab number 8
better way of doing this? :)
March 7th, 2007, 04:13 PM
why are you adding 3 to the getSelectedIndex()??
March 7th, 2007, 06:42 PM
Well I havent figured out any other way of using it! I thought u could specify a tab by its name, can someone give me an example
Here is my code
JMenuItem addCustomer = new JMenuItem("Add Customer",new ImageIcon("plus.gif"));
JPanel new_panel = new JPanel(); //create details panel
tabbs.addTab("New Customer",null,new_panel,"New Customer");
public void actionPerformed(ActionEvent event)
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.