Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add a gui from different class  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have two class like this one

public class gui extends JPanel
{
JPanel panel;
public gui()
{
//GUI code
panel.add(.......);
........
..........
............
}
}


public class gui1 extends JPanel
{
JPanel exp
public gui1()
{
//GUI code
exp=new JPanel(new gui());
}
}


Actually i want to use the components of gui in gui1. What i have done above is correct or not. Someone please guide me through that.


Thanks and Regards
alexander
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adeeb alexander wrote:Hi.
Actually i want to use the components of gui in gui1. What i have done above is correct or not.

Have you tried it? Does it work? If not, are you having specific problems with it?


Someone please guide me through that.

I don't think we can just yet, given the very broad nature of this question. My experience here and on other fora are that the more specific the question, usually the more helpful the answer.

Have you gone through the Sun Swing tutorials yet? If not, I highly recommend that you do as they are very instructive and will likely guide you to answer most of the questions of yours I've seen posted here. Best of luck!
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pete.
I have tried executing the individual progs and i dint get any output until i take a JFrame and add panel to it. Is it possible to get the output by just extending the class with JPanel. If i extend the class with JFrame its fine i get the output. But when i try to use this. Like JTabbedPane tb = new JTabbedPane("Pane",new gui()) . Then i get a execution error "adding Container to a panel................

how to integrate a panel from gui class into a JTabbedPan in gui1 class

Thanks
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz.
You may understand what i need if you look at the code below



This is the other class where i want to use the gui from above class. I know my approach is wrong but i tried like this. I get compilation error:
cannot find symbol method exp()

 
salvin francis
Bartender
Posts: 1479
21
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the class "exp" in the same Package as "exp1" ??
By the way, why are you using lower case chars for Class names ??
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. Both the classes are in the same folder. And the above is just example.




thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!