Over riding methods
So i have an abstract class called Person which has a toString method in it as so
public String toString()
String persDetails = "First Name: " + firstName +"\n" +
"Last Name: " + lastName +"\n";
return persDetails;
}Then i have another class which extends Person. I need to over ride the above toString method. Now normally overriding is just writing a new method with the same signature, with what ever u put in it being the new method. What i need to do is override and call the toString method defined in the superclass, and add barcode variable to it. I cant use a super keyword in a method can i? So how would adding, rather than replacing to an overridden method work?
BalusC wrote:
nick2price wrote:
I cant use a super keyword in a method can i?
That may be true.
You're wrong.To clarify, you are allowed to use super.method() in a method and it can be done.
Similar Messages
-
Problem after over riding paintComponent() method
I am over riding the paintComponent() method for a button to show the text in 2 lines. But when I invoke setEnabled(false) on the button, the button is getting disabled but the text is not.
Could any one please let me know how to do that.
The code for the paintComponent() method is pasted for reference
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
int w = getWidth();
int h = getHeight();
FontMetrics fm = g.getFontMetrics();
int textw1 = fm.stringWidth(text1);
int textw2 = fm.stringWidth(text2);
FontRenderContext context = g2.getFontRenderContext();
LineMetrics lm = getFont().getLineMetrics(text1, context);
int texth = (int)lm.getHeight();
prefHeight = texth;
int x1 = (w - textw1) / 2;
int x2 = (w - textw2) / 2;
int th = (texth * 2);
int dh = ((h - th) / 2);
int y1 = dh + texth - 3;
int y2 = y1 + texth;
// Draw texts
g.setColor(getForeground());
g.drawString(text1, x1, y1);
g.drawString(text2, x2, y2);
regards,
shantanuHi,
Thanks for advices, I solved the problem...it was simplier than i thought. When the g.drawImage(.... is called ) i just added Thread.sleep( time ) after that line. This gives the sound therad time to play the sound without interrput and time to main thread to handle the image. All works now pretty much as i thought, except when JFrame is overlapped the image is not drawn again...this can be corrected ( maybe?)by adding windoslistener and implement the methods in that inteface and make some repainting in different situations. But cause you gave me the magic work Thread priority I hox! the problem, so here goes 10 duke dollars. -
hi i wrote two static methods with same signatures in two different classes. i know that static methods never override.but observe this code..
class staticoverload1
static void display()
System.out.println("i am from first display");
class staticoverload2 extends staticoverload1
static int a=10;
static void display()
staticoverload1.display();
System.out.println("the value of x is:"+a);
class staticoverload
public static void main(String args[])
staticoverload2 s1=new staticoverload2();
s1.display();
i got output as follows:
i am from first display
x value is :10
in the above problem over riding is happened or notPlease post your code in code tags.
s1.display();
Don't call static methods on objects. Tis ugly. But it will use the type of the reference.
class Test {
public static void display() {
System.out.println("Test");
public static void main(String[] argv) {
Test t = new Test2();
t.display(); // Prints "Test". Even if you set it to null.
class Test2 extends Test {
public static void display() {
System.out.println("Test2");
}Finally this should have been posted in New To Java. -
Hi Friends,
We are in a phase of data migration from 11i to R12
I was discussed with client & they wants extraction of all open POs which was generated after 01 Jan 2014 to till date in 11i.
Condition for open POs is PO qty-received qty=>0
critical Example for open PO is :PO no: 10 has 4 lines, 3lines full qty has been received & for 1 line partial qty(say 50 out of 100) received.
in this case he wants in R12 uploading as PO no:10 should entered as open PO with all 4lines & 3 lines complete receipt should be done, for 4th line partial qty i.e 50 should be received.
the question is if we upload on hand qty first, then open POs & receipts, it will increase the onhand qty in new system(mismatch of on hand qty's 11i to R12)
Is it possible to do the onhand qty upload with over riding of all receipts which uploaded against Open PO lines.
Or Please advice best solution.
Thanks & Regards
Giriadetoye50 wrote:
Dear Contacts Journal Support Team,
FYI, this is a user to user support forum. You are NOT addressing Apple here.
Honestly, I doubt anyone is really going to take the time to read the novel you have written. -
How can I decrease my font size in mail? I have it set to small and yet it is enormous, letters running into one another. I have rebooted and more. Something is over riding my setting. Any suggestions?
You haven't mentioned which mail it is,
If it is G-mail go to settings --> general tab--> default text style , you can change your font size & then save at the bottom of the page -
OU Group Policy over-riding User Group Policy
I'm using ZfD 4.01 ir7 and have a restrictive Group Policy applied at the
OU level. I've created a less restrictive Group Policy and assigned it to
a user within the above mentioned OU but the settings are not
taking...the OU Group Policy is over-riding the user Group Policy. The
appropriate rights have been assigned and this configuration is working
for other users/OUs in the tree. I've run a dsrepair against this
partition and no errors were reported.
Any suggestions to resolve this would be greatly appreciated.
RyanPaulr,
It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
- Check all of the other support tools and options available at http://support.novell.com in both the "free product support" and "paid product support" drop down boxes.
- You could also try posting your message again. Make sure it is posted in the correct newsgroup. (http://support.novell.com/forums)
If this is a reply to a duplicate posting, please ignore and accept our apologies and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Product Support Forums Team
http://support.novell.com/forums/ -
Over-riding .LCK files on Inherited Website
Is there any way of over-riding .LCK files?
I’ve recently been given access to administer a
department webpage at a university and defined a site on my
computer - but when I accessed the server's directory I found the
.htm files have the .LCK extension. I was able to download the
files but am prevented from uploading any files. The original
webperson has left and no one has any information.
I was checking the archives and see that the .LCK is related
to Dreamweaver's "check-in/check-out" feature which allows tracking
of files when working in groups. But since I'm now become "the
group", how do I over-ride this feature so I can work on the .htm
files?
~CKJust delete the lck files on the server as I mentioned
before.
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"Hurleyburley" <[email protected]> wrote in
message
news:[email protected]...
> Unfortunately the previous person who opened the files
and checked them
> out did
> not return/upload them - and didn't leave copies of the
files to upload.
>
> So is there a way to access the files which have been
locked when I don't
> have
> the original checked-out files to check-back-in?
>
>
>
>
quote:
Originally posted by:
Newsgroup User
> If the previous person opened the file in DW it would
have checked it out,
> in the process creating the LCK file. To remove this
file DW needs to
> check
> the file back in. If you are using another program for
this part of the
> operation then you will have problems with DW.
>
> --
> Paul Whitham
> Certified Dreamweaver MX2004 Professional
> Adobe Community Expert - Dreamweaver
>
> Valleybiz Internet Design
> www.valleybiz.net
>
> "Hurleyburley" <[email protected]>
wrote in message
> news:[email protected]...
> >
quote:
Originally posted by:
Newsgroup User
> >
> > Thanks alot for the help!
> >
> > I did enable Contribute in my Remote site. I was
able to download the
> > files
> > to my computer and make changes. When I tried to
upload the updated
> > .htm
> > files
> > I got an error message saying "Encountered 1 errors
(sic) during the
> > transfer."
> >
> >
> > Due to security reasons our university permits file
transfers using a
> > product
> > called SSH Secure File Transfer Client. Does using
the SSH FTC product
> > instead of Dreamweaver's FTP connection create a
problem for the .LCK
> > check-in/check-out feature? Or is there something
else that needs to be
> > addressed?
> >
> >
> >
> > You need to NOT do this. Have you enabled
Contribute in your Remote
> > site
> > definition?
> > --
> > Murray --- ICQ 71997575
> > Adobe Community Expert
> > (If you *MUST* email me, don't LAUGH when you do
so!)
> > ==================
> >
http://www.dreamweavermx-templates.com
- Template Triage!
> >
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
> >
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
> >
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
> > ==================
> >
> >
> > "Hurleyburley" <[email protected]>
wrote in message
> > news:[email protected]...
> > > Is there any way of over-riding .LCK files?
> > >
> > > I?ve recently been given access to administer
a department webpage at
> > > a
> > > university and defined a site on my computer -
but when I accessed the
> > > server's
> > > directory I found the .htm files have the .LCK
extension. I was able
> > > to
> > > download the files but am prevented from
uploading any files. The
> > > original
> > > webperson has left and no one has any
information.
> > >
> > > I was checking the archives and see that the
.LCK is related to
> > > Dreamweaver's
> > > "check-in/check-out" feature which allows
tracking of files when
> > > working
> > > in
> > > groups. But since I'm now become "the group",
how do I over-ride this
> > > feature
> > > so I can work on the .htm files?
> > >
> > > ~CK
> > >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
> -
Over-riding the paint() method
I want to create a custom button-rounded sides with straight top and bottom to be exact. I understand that you can use the Component class to create components, and over-ride the paint() method to create the actual button's appearance, but how do you do this? Also how do you go about creating an actionlistener for a component like my button idea? Any help will be appreciated!
Since you are creating your own JButton you want to implement MouseListener so that you can detect the mouse up and mouse down events. If you are going to have a hover image then you want to implement MouseMotionListener as well. Here is an example:
public class MyButton extends JComponent implement MouseListener, MouseMotionListener {
private Vector listeners = new Vector();
public MyButton() {
addMouseListener(this);
addMouseMotionListener(this);
public void addActionListener(ActionListener al) {
listeners.add(al);
public void removeActionListener(ActionListener al) {
listeners.remove(al);
//add the overridden methods from MouseListener, MouseMotionListener
public void paint(Graphics g) {
//paint based on the events
}This class will be notified when the mouse enters, exits, is clicked, etc. and you can set a state variable so that your paint routine knows what image to paint.
Hopefully this will clear it up. Not sure how I can make it clearer. -
Over riding hashtable get and put method
Hi all
Anyone have any idea about over ride HashTable get() and put(). Is it possible to over ride HashTable methods.Yes_me wrote:
I want to change the structure of the java HashTable get and put method. As put method is having two object parameters I want to send one more parameter as String to it. Is it possible to change the structure in this way.What would you want to be returned when calling get()? I would go with the suggestion to create a class to keep that information. If you really want to, you can completely hide that information class inside your extended HashTable. You could create an overloaded put method that takes three parameters and then creates an instance of the information class and put that into the map. If you only want the data for display only, the get method could get the information class mapped to the given key, then simply return a nicely formatted String containing the two values. -
can we override a method marked as static?
rasundo wrote:
You're both right, I should have known the difference between '+hiding+' and '+overriding+' ;).
Now I do (once more again).If you feeling an overriding urge to reply to a forum member's question, first go into hiding and study the JLS. -
Change over from % method to usefl life
asper my client wants
example value of the asset 25000 ,10% staright line method after first year it is 22500, now i need to transfer this amount to new asset in which t-code i can transfer, then only change over method scenario from % method to useful life i want ,where and where i need to assign? please tell me where can i transfer this 22500/ but sytem is taking in ABUMN the full amount of 25000/ it is not taking 22500.
please solve me the issue, provide stepsHi
In ABUMN - Tab Additional Details - You need to choose the proper transfer variant...
if you choose Net Method - I think it would transfer @ 22500
In the New asset master - choose a dep key which is based on Useful life....
br, Ajay M -
Sales Order to Drop Ship Purchase Order -- Carry Over Ship Method?
Hi everyone,
When I create a sales order in B1 using the 99 warehouse, it automatically generates the purchase order once the transaction is billed/invoiced.
This purchase order does not have the same shipping method as the sales order. I have worked around this in Crystal Reports, but is there a way to have SAP carry over the ship method?
Thanks,
ChrisHi Chris,
This may only be done through SDK. There is no standard function to achieve it.
Thanks,
Gordon -
Over-riding equals()
Hi all
I am a little lost with a code and any kind of help/suggestion would be appreciated
The default HashMap in Java which maps a key to a value works fine with normal objects like wrapper classes,etc since they have a natural ordering
But I want to change the way it compares two keys since the object that would be inserted would not have a natural ordering
The key to my HashMap would be a Range object which goes like this
class Range
int lowerRange;
int upperRange
so for this hash map to behave correctly i.e. map the keys to values correctly I will have to override the equals method.
Can anyone suggest the pseudo-code for doing this?
When i tried to create my own class that extended from HashMap and tried to over-ride the equals(Object object) i was all lost since i didnt get what should i compare the object with?
Am i approaching it all wrong?
Thanks & Regards,
PrameelaYou would have to do both equals and hashCode.
When i tried to create my own class that extended from HashMapWhy are you changing HashMap? You need to add an equals/hashCode to the key. -
Over-riding automatic save/copy of "sent" e-mail ??
Is there any way to over-ride (for a single message) the automatic save/copy of "sent" e-mail ?? ie there are occasions when I DON'T want to keep a copy.....
As far as I'm aware, you can choose to either save a copy or not.
This is set up in your Account Settings> copies & folders for the mail account.
I'm not aware of any method that lets you preselect to not save a particular email. Other than changing the Account Settings prior to creating the email and then resetting them again after sending.
The only option would be to save all as auto and delete what you do not want. -
Benefit of Delegate over regular method
Hello.
I was looking over a library's code and saw a delegate function for processing an IDataReader row's columns.
What is the advantage of declaring the function this way as opposed to declaring a regular, static function:
Alias:
static Func<IDataReader, MyEntity> Make = reader =>
new MyEntity
MemberId = reader["MemberId"].AsId(),
Email = reader["Email"].AsString(),
CompanyName = reader["CompanyName"].AsString(),
City = reader["City"].AsString(),
Country = reader["Country"].AsString()
Regular static method:
private static MyEntity Make(IDataReader reader)
return new MyEntity
MemberId = reader["MemberId"].AsId(),
Email = reader["Email"].AsString(),
CompanyName = reader["CompanyName"].AsString(),
City = reader["City"].AsString(),
Country = reader["Country"].AsString()>What is the advantage of declaring the function this way as opposed to declaring a regular, static function:
Scope. They are functionally identical, but I do this sometimes to keep all the functionality inside a single method. Notice how the method uses the DataReader column names, which in turn come from the SQL Query. If you put this in a separate
method you'd have to keep them in sync.
The choice here is probably between using an anonymous method, or pasting the body code at the call site. You do this when you want to avoid verbose or repeated code in the method. But where you don't want to reuse the code in any other method.
David
David http://blogs.msdn.com/b/dbrowne/
Maybe you are looking for
-
Hi everyone, I recently upgraded to Adobe XI and I can't find a "submit by email" button for my form. I created a button and tried to set up some actions but, I can only get the button to direct the user to a URL. How do I make it send the completed
-
Adobe indesign CC on mac X 10.7.5 - freeze when package file for print
Has anyone else had this problem or can suggest a solution? When I have a file in indesign ready to print i go to package it and it get to the little loading bar and freezes indefinitely. No package and i have to force quit. Real pain! HELP!
-
I am running into this issue with Adobe AE CC 2014 with both Mac and Windows versions in a classroom. Macs are running Mavericks, Windows are Win 7. Mac version of AE is 13.1.1.3. All CC 2014 apps are up to date. If I have a text layer selected and c
-
I have a DVD which has files in .VOB format. Does anyone know of a Mac translator that will convert them to quicktime so I can use them in iDVD???
-
I would like to safe the XMP files in the same location as the original raw files, so I can copy and backup them on different computers. How can I do that by default ? Where on my pc is the location of the xmp files I created already for the differe