Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JTabbedPane - calling a class

Status
Not open for further replies.
Aug 23, 2004
174
0
0
US
I am trying to call a class from a tabbed pane and im getting an error - cannot find symbol method addTab(java.lang.String.PoolPage)

I have a separate class, PoolPage. here is the line that is giving me the error.

PoolPage p = new PoolPage();
tabbedPane.addTab("Pool", p); - ERROR

Any ideas?
Thanks
 
Assuming you're using Swing (JTabbedPane), is that PoolPage class descendant of Component?

Cheers,
Dian
 
Im not sure I understand what you are asking.

I can change the code around so the pane calls a method, tabbedPane.addTab("Pool", poolPanel()); and it works fine.
 
Well in one example, you are passing in a class named 'PoolPage', and in the other you are passing in 'poolPanel' - so which does it accept ? Are you sure both classes subclass Component ? I suspect not ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
thats exactly the problem. when i pass the method poolPanel everything works fine, when i try to use a class instead of the method i get an error.
 
So I refer you to both mine, and Dian's previous questions about subclassing Component .

Without any actual errors, stack trace, or code, I find it hard for use to help you any further.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Which point ? Do you :

a) Not understand what an error is ?
b) Not understand what a stack trace is ?
c) Not understand what code is ?
d) Not understand what subclassing the Component object means ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Well the addTab() method's second parameter accepts a Component object.
So whatever object you pass in, must be a subclass og Component (ie, if you want to create your own class, then you must extend Component).

I really feel, if you do not know what it means ti "extend a class" or what subclassing is, then you really should go back to Java 101, and come back to Swing later.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Oh, i understand now. I didnt know subclassing was the same as extending a class.

As far as Java 101, im just completing my first java class and trying to do some extra projects for myself, thats where this project is coming from.

So let me explain the program. Im creating a tabbed pane with 5 tabs. I want to be able to click on the tab and have it call a class (poolpage) and have that class display the contents for that page. The tabbed page is setup fine, and now the only problem is calling the class from the tabs.

How should I go about doing this?

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top