• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Add a class from different package and add it to JTabbedPane

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,

I have a class Staff which has a JTabbedPane. I want to add a JPanel in the JTabbedPane from another class UpdateProfile (which is on another package). Can anyone help me with that.
I am new to java and recently i moved from gui builder to manual coding so i need a help here. I know its pretty confusing but please take a time to solve this problem.



In the above TabbedPane i want to add the class have constructor as below
 
Saloon Keeper
Posts: 5233
211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi John,

is your class 'UpdateProfile' a class that extends JPanel? If not, then update in line 5 cannot be of type JPanel
 
Sheriff
Posts: 27527
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even more confusing without knowing what the error message says. However... if your UpdateProfile class is going to contain a JPanel, as in your constructor code, then it will need a getter method for users of the class (such as your Staff class) to get a reference to that JPanel. Right now you only have a local variable in the constructor which refers to the JPanel, so you'd need to fix the UpdateProfile class to have an instance variable to hold that reference.

Or if the UpdateProfile class is intended to actually be a JPanel, as Piet guesses, then it should extend JPanel instead of creating one.
 
John Path
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys for your help,

Now UpdateProfile Class extends JPanel,

But still i am finding errors

Staffs Constructor


UpdateProfile Constructor now it extends JPanel


While running managingSTaff class it shows the following error


 
Paul Clapham
Sheriff
Posts: 27527
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This appears to be an error message from some code you haven't shown us. Or am I wrong?

It would be more helpful to show us the whole stack trace and not just one line of it. That way it's possible to identify the context in which the error occurred.
 
Rancher
Posts: 3288
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post a proper SSCCE when asking a question.

We can't guess the context of how the code snippets are used.
reply
    Bookmark Topic Watch Topic
  • New Topic