Solved

Inherited JPanel

Posted on 2004-08-03
7
259 Views
Last Modified: 2010-05-18
I have a class which has inherited a JPanel.  This JPanel has every thing I need (ex: TextareaBoxes, Dropdowns, etc).

I would like to put the following code inside the inherited JPanel.  How can that be done?
public class myClass extends thisClass
{
....
public void customPnl();
{
button1                      = new JRadioButton(temp.getString("button1"), true);
button2                      = new JRadioButton(temp.getString("button2r"));
sLbl                           = new JLabel(temp.getString("subject"));
GridBagLayout layout   = new GridBagLayout();
GridBagConstraints c   = new GridBagConstraints();
}
public void Make()  //This function creates the whole UI
{
JPanel Pnl = buildPnl();
setLayout(new BorderLayout());

JPanel pnl2 = buildPnl2();
add(buildPnl(), BorderLayout.NORTH);

JPanel pnl3 = new JPanel(new BorderLayout());
pnl3.add(pnl2, BorderLayout.CENTER);

add(pnl3, BorderLayout.NORTH);
add(buildPnl(), BorderLayout.NORTH);
add(pnl3, BorderLayout.CENTER);
}
}

...Currently only the inherited class's UI is showing up.  How can I put the radiobuttons from the function customPnl()?
0
Comment
Question by:JK2429
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11708562
public void customPnl(JPanel panel);
{
button1                      = new JRadioButton(temp.getString("button1"), true);
button2                      = new JRadioButton(temp.getString("button2r"));
sLbl                           = new JLabel(temp.getString("subject"));
GridBagLayout layout   = new GridBagLayout();
GridBagConstraints c   = new GridBagConstraints();
panel.add(button1);
panel.add(button2);
panel.add(sLbl);
//and other layout works
}

customPnl(pnl3);

Are u looking somen thing like this??

Regards
Sudhakar

P.S:
You need to adjust ur layouts. I just give an idea
0
 
LVL 4

Author Comment

by:JK2429
ID: 11708771
No, this will not work, because Make() is used in the main function to make the Panels and grids.  I need something in the Make() or customPnl() which will give me the results.

Thanks.
0
 
LVL 4

Author Comment

by:JK2429
ID: 11715533
Here is the heirarchy of classes.

I need to use a function5 which is in class1.  Class2 inherits Class1.  Class3 inherits Class2.
Function5 needs to be implemented in class3.

Class1
   |
   ---Class2
          |
          ---Class3
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:JK2429
ID: 11874331
Any answers??  If no comment is posted in a week, I will ask the moderator to close this question.

Thanks.
0
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 11880155
Does Class2 have a function5 method in there? Then you can simply call it by doing super.function5(). If you need to override it then do something like:

public void function5()
{
   super.function5();
   /// your implementation here.
}
0
 
LVL 4

Author Comment

by:JK2429
ID: 11884084
That did the trick..
0
 
LVL 35

Expert Comment

by:girionis
ID: 11884171
Thank you for accepting :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now