aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Design / Development Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Design / Development Question" Watch "Design / Development Question" New topic
Author

Design / Development Question

Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
First off, I am 'green' to Swing, but past beginner with Java. I am working on the base design of a fairly basic GUI using Swing, which consists of a dozen or so tabs. I would like for each tab to be constructed in its own class file, so that simultaneous work may be done by developers on individual tabs.. And then have it called from a main GUI class file which puts it all together and makes it appear (does that make sense?). All of the JTabbedPane examples I have seen construct the entire GUI in one large class file, rather than seperate files. Does anyone know of any examples, or suggested reading, which would help me understand how to properly achieve this result?

Thanks for any help.
[ February 18, 2008: Message edited by: Brad Walton ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

It's not all that difficult. What I do is create a separate class for each container that will exist in a tab. Then I instantiate each one I need and call tabbedPane.addTab(); Something like this:



Each of the above classes would be in its own file. And that was major pseudo code so use it as a template, not verbatim.


GenRocket - Experts at Building Test Data
Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
Thanks Gregg. Appreciate the help!
Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
Hmm.. I'm having a little trouble with the construction of it (i.e. in FormOne()). Can you provide a quick example of that? I am getting an error when adding it in Main, which is looking for the String, Component.. I am constructing it as a JTabbedPane in the FormOne class but that doesn't seem to be working.

Thanks again.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Brad Walton:
Hmm.. I'm having a little trouble with the construction of it (i.e. in FormOne()). Can you provide a quick example of that? I am getting an error when adding it in Main, which is looking for the String, Component.. I am constructing it as a JTabbedPane in the FormOne class but that doesn't seem to be working.

Thanks again.


Again, my code was just a template. If you look at the API for JTabbedPane.addTab it requires a String as the first argument which will become the Title of the tab. If you continue to have problems, please post your code. It is easier to debug if we have something to look at.
Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
See next post...
[ February 19, 2008: Message edited by: Brad Walton ]
Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
Well I finally got it working, but I am not sure if this is the best way to do it, or the method being described in the template above.

Component creation class:


And in the main GUI class:


Have I got this right? Or is there a better way?

Thanks!
[ February 19, 2008: Message edited by: Brad Walton ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design / Development Question