Solved

Inherited JPanel

Posted on 2004-08-03
7
266 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

730 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