This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes inherritence problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inherritence problem" Watch "inherritence problem" New topic
Author

inherritence problem

twin yan
Greenhorn

Joined: Oct 07, 2012
Posts: 18
hello all

well , basicly what i'm trying to do is adding another small method to an excisting java class (ImageIcon)
any ideas if it's possible and in which direction should i go ?
thanks to all helpers!
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Did you write that class?
twin yan
Greenhorn

Joined: Oct 07, 2012
Posts: 18
well i tried this :



but no go, i'm missing something
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
What do you actually want to achieve?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60763
    
  65

Maybe you could expand on what "no go" means?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
twin yan
Greenhorn

Joined: Oct 07, 2012
Posts: 18
trying to get a method in there that will scale the photo to a certain height and width , the ImageIcon img1 is unneccesery just delete that

and i want that method to work on ImageIcons in my project
that's the goal
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7503
    
  18

twin yan wrote:trying to get a method in there that will scale the photo to a certain height and width...
and i want that method to work on ImageIcons in my project ... that's the goal

OK, but I'm not quite sure how extending the class will help, unless you plan to make every Icon in your project "scaleable".

You've also written the method as if it was static. If you're writing it as an instance method for a 'ScalableIcon' class, then surely the method will act on the instance it's called on, so the signature should be:

public ImageIcon scale(int width, int height) {
   // code to scale 'this'
...


There's nothing basically wrong with what you've done, but to me it looks more like a static "utility" method; so if it was me, I'd probably put it in something like an 'ImageUtils' class.

HIH

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inherritence problem
 
Similar Threads
WA #1.....word association
session info
Are calculators allowed on the exam?
Ejb Project Plan
Java and other languages