Solved

Inherited JPanel

Posted on 2004-08-03
7
260 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split string containing \r\n in Java 46 44
session migration servlets 2 38
fibonacci ten numbers 4 39
hibernate example for saving data 19 43
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

821 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