Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

inherritence problem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Rancher
Posts: 1043
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you write that class?
 
twin yan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i tried this :



but no go, i'm missing something
 
Ivan Jozsef Balazs
Rancher
Posts: 1043
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you actually want to achieve?
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic