• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inherritence problem

 
twin yan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you write that class?
 
twin yan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i tried this :



but no go, i'm missing something
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you actually want to achieve?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could expand on what "no go" means?
 
twin yan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10273
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic