Solved

Inherited JPanel

Posted on 2004-08-03
7
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

719 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