jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes JtabbedPane & bringing in other classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JtabbedPane & bringing in other classes" Watch "JtabbedPane & bringing in other classes" New topic

JtabbedPane & bringing in other classes

Shannon Keough

Joined: Oct 12, 2001
Posts: 4
I'm writing an application that has 5 or 6 classes. I want to set up the application in a JTabbedPane. At this moment, each class has its own JFrame & contentPane. I have tried to combine all of these into a JTabbedPane with no success. I think I have to extend JFrame in the MainTab class (the class with the JTabbedPane)and extend JPanel for the rest of the classes.
I also have to get rid of the JFrame in each of the other classes and then create an instance of a class within one of the tabs. I can't seem to be able to bring the other classes into one of the panels in MainTab.
I guess My question is how do I create in instance of another class and bring it into a certain tab(panel)
Here the code that i have tried & commented out & rewrote too many times to count.
I'm sure that it is something very stupid that i'm doing wrong.
Unfortunely, at this moment my system is out of resources & won't let me compile this code.

Thanks in Advance
import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
//declare the public class
public class MainTab extends JFrame
public JPanel p1,p2,p3,p4,p5;
public JLabel l1;
public JTabbedPane tp1;
public JFrame f1;
public Container contentPane;
public void draw()
tp1=new JTabbedPane();
l1=new JLabel("Test");
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
p5=new JPanel();

Client c1=new Client();

f1=new JFrame("Sell My Home Realtors");

//set the frame size and make it visible
f1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
public static void main(String []args)
MainTab mt1=new MainTab();
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

And here is the tab1 class file

How's that??

Happy Coding,
Gregg Bolinger

GenRocket - Experts at Building Test Data
Shannon Keough

Joined: Oct 12, 2001
Posts: 4
Thanks for the answer but I still can't get it to work. the code is compiling however there is nothing showing in the window. The window is in the upperleft corner. When you maximize the window, you don't see anything but the blank frame.
I think I'll try a CardLayout & see if I can make that work.
Gregg, Thanks a million.
My previous reply was premature. I kept at it and finally got it to work. It seems that to make it work, I had to use this.add to the final panel of the classes I was trying to bring in.

[This message has been edited by Shannon Keough (edited October 13, 2001).]
I agree. Here's the link: http://aspose.com/file-tools
subject: JtabbedPane & bringing in other classes
It's not a secret anymore!