Solved

Inherited JPanel

Posted on 2004-08-03
7
258 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

758 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

21 Experts available now in Live!

Get 1:1 Help Now