JPanel methods arn't being overriden in my subclass.
Basically I have a JPanel class which I want to use as a template (super class) for other GUI Items. These other GUI items extend off this class, but also have the ability of altering the appiernece of the panel by overiding some functions. As far as I can tell, they arn't overiding.
Here's an example of what I'm trying to do.
package lastGUI;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
* A template Panel
* @author Yves Samuel Wheeler
public class Template extends JPanel {
private static final long serialVersionUID = 1L;
private JSeparator Separator;
public Template() {
super();
initGUI();
private void initGUI() {
instantiateComponents();
add(buildMainPanel());
private void instantiateComponents() {
Separator = new JSeparator(JSeparator.VERTICAL);
private JPanel buildMainPanel() {
FormLayout formLayout = new FormLayout(
"pref:grow, 15dlu, pref, 15dlu, pref:grow", // columns
"15dlu, pref:grow, 15dlu"); // rows
PanelBuilder panelBuilder = new PanelBuilder(formLayout);
CellConstraints cellConstraints = new CellConstraints();
panelBuilder.add(buildLeftPanel(), new CellConstraints(
"1, 1, 1, 1, fill, fill"));
panelBuilder.add(Separator, cellConstraints.xywh(3, 1, 1, 3));
panelBuilder.add(buildRightPanel(), new CellConstraints(
"5, 1, 1, 1, fill, fill"));
return panelBuilder.getPanel();
protected JPanel buildRightPanel() {
FormLayout formLayout = new FormLayout("pref", // columns
"pref"); // rows
PanelBuilder panelBuilder = new PanelBuilder(formLayout);
CellConstraints cellConstraints = new CellConstraints();
panelBuilder.addLabel("Right", cellConstraints.xy(1, 1));
return panelBuilder.getPanel();
protected JPanel buildLeftPanel() {
FormLayout formLayout = new FormLayout("pref", // columns
"pref"); // rows
PanelBuilder panelBuilder = new PanelBuilder(formLayout);
CellConstraints cellConstraints = new CellConstraints();
panelBuilder.addLabel("Left", cellConstraints.xy(1, 1));
return panelBuilder.getPanel();
package lastGUI;
import javax.swing.JPanel;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
public class MyPanel extends Template {
public MyPanel() {
super();
// TODO Auto-generated constructor stub
protected JPanel buildRightPanel() {
FormLayout formLayout = new FormLayout("pref", // columns
"pref"); // rows
PanelBuilder panelBuilder = new PanelBuilder(formLayout);
CellConstraints cellConstraints = new CellConstraints();
panelBuilder.addLabel("This Panel has also been overiden!",
cellConstraints.xy(1, 1));
return panelBuilder.getPanel();
protected JPanel buildLeftPanel() {
FormLayout formLayout = new FormLayout("pref", // columns
"pref"); // rows
PanelBuilder panelBuilder = new PanelBuilder(formLayout);
CellConstraints cellConstraints = new CellConstraints();
panelBuilder.addLabel("This Panel has been overiden!", cellConstraints
.xy(1, 1));
return panelBuilder.getPanel();
}Any help would be apprieciated.
Thanks :)
The MyPanel methods are overriding the parent methods alright.
If you try:
public static void main(String[] args)
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new MyPanel());
frame.pack();
frame.setVisible(true);
}the overriden panels shows up.
Can you post the snippet where you call the MyPanel class?
Similar Messages
-
Help creating an instance of an internal JPanel method?
I hope my terminology for this question is correct but I will describe my problem also.
I have several class files but the 2 classes relating to my problem are Main.java and MapNavigation.java
Main.java is my application JFrame to which I add other JPanels.
I would like to add an internal JPanel method from MapNavigation.java to main but do not know how to reference it?
How would I reference the JPanel method in MapNavigation in order to add it to my GUI in Main?
public class MapNavigation
public class ControlPanel extends JPanel implements ActionListener
public ControlPanel()
class Main extends JFrame
public Main()
// I wan't to add ControlPanel from MapNavigation.java here!
}Thanks in advance
I'm very new to java and still have limited knowledge, all of your help is very much appreciated.
DaveHi, I tried your suggestion but I get the error:
C:\Documents and Settings\Dave\Desktop\src>javac Main.java
Main.java:20: cannot find symbol
symbol : class MapNavigation
location: class MapNavigation
MapNavigation.ControlPanel MNCPanel = mapNavigation.new MapNavigation();
^
1 error
what would you suggest to be a better method to my problem as I'm using MapNavigation as a class that extends ViewPlatformAWTBehavior for the controls of my application so therefore cannot add the class directly to my GUI and therefore have to add a method contained in the class.
Thanks in advance
Dave -
Which method of two interface are being overriden
Hi all,
I have a query.
There are two interfaces interface one interface two. and both declare a method void common()
A class three implements one, two
and implements the method common()
void common() {
System.out.println(" which interface");
so in this case the common method of which interface is being called there
ThanksHi,
I don't understand your question. The implementation
of a method in a class does not belong to an
interface. You only say that you fulfill a contract,
so the method fulfills the contract of both one and
two.
One thing you have to be careful of though: The method fulfills both contracts to the extent that the compiler can check. However, the API docs that describe the semantics of the methods may be radically different, and it might be impossible or nonsensical to fulfill both. -
DoSuccessAuth method is not being called
I extended weblogic class AuthFilter and i overwrited the
following method: public boolean doSuccessAuth(ServletRequest
req, ServletResponse res)
I have 2 war files. When i login successfully into the first war
file the function doSucessAuth is called. Then i have a link
(URL) in the jsp page in the first war file that takes me to the
another other JSP page in the second war app. When i am in the
second war the doSucessAuth is not been called at all. When i go
back to the first war file; it is being called.
But i am sure that the second war is authenticating the user.
Why this doSucessAuth methos is not been called by WL 6 sp1 on
NT when the user is accessing the jsp pages of the 2nd war app.
PS. I included the following tag <auth-filter> in both
weblogic.xml for the 2 app war.
Thanks{color:#ff0000}{size:20px}CROSS POSTED{size}{color}
[http://forums.sun.com/thread.jspa?threadID=5334750]
[http://forums.sun.com/thread.jspa?threadID=5334748]
Cross posting is rude.
db -
Help Determining Which Methods/Classes Are Being Used
Hello,
I'm having issues with my company's Java application and because I've luckily narrowed the classes down to a meager 30+ I need some help pinpointing my problem.
I realize there are a lot of Java monitoring applets/applications and some are deployment-specific but I need something very detailed-- I haven't found the features I need.
Specs:
Jrun4, Java 1.4, Windows Server 2003
I would like to have a monitor that tells me exactly (real-time) what classes, methods, variables, etc. are being called in real-time. Looking at the JRun launcher console for one process gives me this:
Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
01/16 14:05:33 error Software caused connection abort: socket write error
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at jrun.servlet.io.MetricsOutputStream.write(MetricsOutputStream.java:75)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:106)
at jrun.servlet.http.WebOutputStream.write(WebOutputStream.java:64)
at jrun.servlet.file.FileServlet.pipeData(FileServlet.java:419)
at jrun.servlet.file.FileServlet.service(FileServlet.java:254)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)This is cute, but not really helpful. I would like to determine what was passed to the process, from where and what went wrong.
For example,
Instead of this:
Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
01/16 14:05:33 error Software caused connection abort: socket write errorI would get something like this:
Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
Page variables: test.jsp ($var1= "I'm"; $var2= "Going"; $var3="To"; $var4="Break"; $var5 = null)
Calling: test2.jsp
With: jrun.bin.db.foo.Bar();
01/16 14:05:33 error Software caused connection abort: socket write error
Problem: $var5 = null;Sorry if I'm rambling, I just want to know what is where and who it's calling when it breaks. Then I could deduce which class, what variable, what page, etc. My application is very complicated and seemingly mundane changes can throw it all off.
Any ideas?We'll look into usage tracking. We're on the standard edition, so I'm not sure if it's available. Also, some of these reports may be quarterly -- so there may be a long wait to see if the view is used and I need to know fairly soon. (If it's not used, it saves us some work in a project transition going on.)
I certainly don't understand the underlying structure of the product, but it seems like there should be some way to determine if a view is used by a report. I apologize if I'm not using the correct terminology. Thanks for your help -- we'll keep looking into it. -
Two of Three internal speakers arn't being used in Black Macbook (2006)?
Hi,
I probably tinker with my Macbook too much, however I noticed today that sound is only coming through the one internal "woofer" speaker, or the speaker that faces up at the F8 key. When using the internal speakers, not using an external output in other words, the two stereo speakers that face back toward the lcd screen on the left and the right sides of the case do not emit sound at all. I've checked the connections of each, I've played with settings in the System Preferences, and I've tried several different settings in iTunes. I cannot get the Macbook to use those speakers.
Is there some software glitch in the Kernal or Firmware that is preventing these from being used? Or could it be a hardware or sound card issue? I have no idea. It isn't something critical or anything, the single speaker in the middle works fine, however, I imagine the Macbook's internal audio quality and volume would be much improved if it were using all of the speakers installed.
Any ideas or thoughts?
About my Macbook:
Black Macbook (2006)
2 GHz Intel Core 2 Duo
2 GB of RAM
500GB SATA Hard Drive
OSX 10.6.8 w/ Windows 7 H.P. Bootcamp Partition
Any help would be much appreciated.Try resetting the SMC and PRAM
Intel-based Macs: Resetting the System Management Controller (SMC)
About NVRAM and PRAM -
Repaint() method is not being called?
Hi...experts
I have appended the unicode characters to the StringBuffer .and i draw it on canvas.
now i want to delete these unicode characters from last index of StringBuffer with the command "Clear" .
i m using the following code for doing this....
StringBuffer sb=new StringBuffer();
sb.append('\u093E');
sb.append('\u093F');
sb.append('\u0940');
sb.deleteCharAt(sb.length()-1);But the StringBuffer is as it is.
please suggest me how repaint() method works.
Edited by: RavindraDiwakar on Sep 25, 2008 7:46 AM{color:#ff0000}{size:20px}CROSS POSTED{size}{color}
[http://forums.sun.com/thread.jspa?threadID=5334750]
[http://forums.sun.com/thread.jspa?threadID=5334748]
Cross posting is rude.
db -
What happened to all of the JPanel methods?
It seems that starting with JRE version 1.8.0_31 all of the methods are missing from the the javax.swing.JPanle class. If compile with JRE <= 1.8.0_25 you swing app is fine, but if the user has >= 1.8.0_31 your app will crash.
Turns out it was something simple. I created a ticket, and got the answer back. I clicked on "my details" under my name in the top right. I then checked and enabled "content editing". Somehow it must have gotten disabled because I was using Muse.
-
Home tab changes are being overriden on every SP upgrade
Hello,
I would like to put an iView I've created in the Documents section of the Home tab of every user.
In order to do that, I have delta linked my iView to the Documents workset located under: Portal Content->Content Provided by SAP->End User Content->Standard Portal Users->Worksets->com.sap.km.worksets->Documents.
Everything is working well the only problem is that this this role (and workset) are managed by SAP therefore after every SP upgrade we are making this document workset is being overridden and I need to set the delta link to my iView again.
On the other hand, I don't want to create my own role and assign it to the Everyone group, I prefer using the Home one already exists.
Any ideas...?
RoyHi Roy,
1.Why don't you create an additional Worksets which contains your iview and a deltalink to the SAP Workset? So changes to this SAP workset would affect your workset but the iView would be still there.
2.You could a non-delta-link copy of the workset and add your iView? But changes wouldn't be drawn to your modified workset.
Solution 2 would be best maybe, because SAP wouldn't change this workset so often, i guess.
Regards,
Marcus -
The videp down load helper isn't working? Video's arn't being downloaded.
I do what seems to be right with no results.
Try the Video DownloadHelper forum
* http://forum.downloadhelper.net/forum/3 -
Overwriting a method of a super class in the subclass ???
Hi,
can somebody tell me whether it's possible to add a new implementation of a method in the sub class which is inherited from a super class?
I want to model my program in that way:
1. I define a super class with some implemented methods.
2. This class should be inherited in a sub class. One method should be used as it was implemented in the super class but another method should be overwritten in the subclass.
I know this concept from Java but I couldn't find a way how to do it in ABAP
Many thanks for any help!
Best regards,
Birgithi,
yeas you can do it,
Subclass can re-implement the inherited public and protected methods from superclass.Class C1 contains method METH1(public) and METH2(protected), both of which are modified and re-implemented in its subclass C2.also you can have ur own methods in subclass.Objects are created out of both classes and the method METH1 for both objects are called.
Output of the program demonstrates different behaviour for method METH1 of class C1 and C2.
This demonstrates the theme.
REPORT YSUBDEL.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS : METH1.
PROTECTED SECTION.
METHODS METH2.
ENDCLASS.
CLASS C1 IMPLEMENTATION .
METHOD : METH1.
WRITE:/5 'I am meth1 in class C1'.
CALL METHOD METH2.
ENDMETHOD.
METHOD : METH2.
WRITE:/5 ' I am meth2 in class C1 '.
ENDMETHOD.
ENDCLASS.
CLASS C2 DEFINITION INHERITING FROM C1.
PUBLIC SECTION.
METHODS : METH1 redefinition,
meth3.
PROTECTED SECTION.
METHODS : METH2 redefinition.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD METH1.
WRITE:/5 'I am meth1 in class C2'.
call method meth2.
endmethod.
METHOD : METH2.
WRITE:/5 ' I am meth2 in class C2 '.
ENDMETHOD.
METHOD : METH3.
WRITE:/5 ' I am own method of class C2'.
ENDMETHOD.
endclass.
START-OF-SELECTION.
DATA : OREF1 TYPE REF TO C1 ,
OREF2 TYPE REF TO C2.
CREATE OBJECT : OREF1 , OREF2.
CALL METHOD : OREF1->METH1 ,
OREF2->METH1.
hope it helps,
regards -
OOPs Concept ! - Why Static Methods can't be redefined in its subclass ?
Dear Experts ,
I had searched the SDN , but unable to find out the satisfactorily answers ..
Can anybody let me know the reason for the following Confusion in Oops Concept
Question 1: As we know , We can Inherit the Static Methods in the Sub Class , But we can't redefine it in the base class or Sub Class ?
Question 2 : Why can't Static Method be Abstract ?
Question 3 : Can a Class be Abstract or Final Both, If yes, then why ?
Thanks in Advance
Saurabh GoelAs per the above discussion two of your doubts have already been clarified so I am taking only third one.
A class cannot never be Abstract and final both coz Abstract signifies that the implementation of the class has not been defined completelyi.e. may be some methods have been defined but few methods are still missing implementation. 'Final' is used for those classes/methods which cannot be redefined means the complete implementation of the method has been defined no one can implement further logic under the same method.
If you are saying your method is Final then it cannot be overridden and Abstract implies that method implementation is yet to be defined which can only be implemented if that class/method is not 'Final'. So both the terms are contradictory.
Hope it clarifies!!!
Thanks,
Vishesh -
Variable scope within an interface and some questions
I am creating a DataStorage interface with a member variable (can I call it a member variable when it is in an interface?) called dataObject. From what I remember, and what the compiler is telling me, the scope declarations "private," or "protected" can not be used on either methods or member variables in an interface.
Now I have another class DataInput that implements DataStorage and I want to make the dataObject private and put in accessor methods to get to the dataObject. But I also remember reading something that said, during inheritance you can not make the scope of the method (and variable?) more narrow. Meaning if a method was defined as default in the parent class, the subclass can not override that method to give it private access all of a sudden.
Now a couple of questions with this...does that rule only apply to subclassing (that is with extends) or does it also apply to implementing interfaces. Second question, I am pretty sure that rule applies to methods that are being overriden, but does it also apply to variables in an interface...because if that is the case, I can't re-declare the variable in the class that implements the interface to be private...and then there is no way to protect that variable.
By the way I did re-declare the variable in the subclass (implementing class) and declared it as a private, and it works...but I'm still trying to figure out the general rule.well if the interface variables are implicitly public static final, how come I am able to re-declare the variable name within the class that implemented the interface.
If for example in interface Car there is a variable color, how come in class Honda implements Car, I can redeclare the variable color, and give it public access. I thought final meant final, no redeclaring...but does that not hold for static variables? -
In Pre-Exit, prevent method from being called
I have created an enhancment for a webdynpro component. Then, I have defined a pre-exit for a method in the component controller. Inside the pre-exit, I do a couple of checks, and depending on them, I would like to skip the processing of the method for which I have define the pre-exit. Is this possible?
I thought of the RETURN statement, but this won't help. RETURN will jump out of the pre-exit, but not out of the method.
my-pre-exit-of-method-SET_MY_VALUE.
IF some_condition = some_value.
"prevent the method SET_MY_VALUE from being called. but how??
ENDIF.
end-of-pre-exit.I just find out how to circumvent this...
The trick is to use "Overwrite exit". Add your own codes. Depending on your conditions, you can call back the original method. But when you call the original method, you need to use the syntax:
me->original_method(...)
Do not use:
wd_this->original_method(...)
Using "me" will only call the original method; using "wd_this" will trigger your overwrite exit which means this will jump to a recursive call to your own exit; This will certainly drain the resources of your system indefinitely until it dumps.
Brian H. -
JUnit/DBUnit rollback inserts/updates made by method being tested
When performing JUnit/DBUnit testing, when you setup your data by inserting/updating rows during initialization, those insertions and updates would be rolledback automatically during the TearDown step of the Unit Test, right?
My question is that if the inserts and updates are done on the method being tested what are the steps to rollback those inserts and updates?
Can it be done implicitly by JUnit/DbUnit? or do we have to do it manually?
We have an ADF Application Module method that is being J/DB-Unit tested and it calls a stored procedure that does a lot of things to many tables on the database. So it would be nice if the rollback was implicit.Anton,
That would be nice, wouldn't it.
Unfortunately, that's not the way it works. You have to rollback/undo your changes explicitly. As you asked on another thread, flashback would be a nice way of doing it. If you have a suite of tests that runs, you can flash back the entire database at the end to put the DB back into a known state.
John
Maybe you are looking for
-
My MacBook is just a few days old and I purchased the Mountail Lion software earlier today. However the icon on the launchpad just keeps saying waiting and occasionally if it does begin to download will not progress and the download will eventually s
-
Could not find the main class ! exception.
hi, I create one java project. for this I am using netbeans 5. I try to run the project jar file stff.jar. When run using "java -jar stff.jar " , it throws error "could not find the main class. program will exit". I am extracting this jar file, in ma
-
How to use tab to link to other page in other application
Hi all, I noticed that tabs does not have the option URL for the Target. It only has current page. Is it possible to link a tab to a page in another application in the same workspace? Thanks. Allen
-
Oracle Service Registry+Jdeveloper
Hi All, I am trying to integrate Jdeveloper with Oracle Service Registry. I am referring to the Developer Guide for OSR and i want to do the following section: *4.1.2. Using the JDeveloper Integration* Once you have established a connection to Oracle
-
Any file that I download that is dmg will not open. I get the message that it failed to mount. If I check get info on the file it says it should open with disk image mounter. when I click on it it eventually says device not configured. I tried openin