Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Using Protected Methods, in a Java Library

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Thanked 0 Times in 0 Posts

    Default Using Protected Methods, in a Java Library

    Hey, there are a set of java image processing classes I want to use.
    It is a library online... "JHLabs Java Image processing"...

    Download Java Image Processing Classes

    The java docs are here...

    For example the class EdgeFilter ... I cant use because the the method that actually does the Edge filtering is a protected method

    protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace )

    Same with ErodeFilter etc.. I can make instances of these classes but I cant use its actual necessary function.
    That is same with all the image classes that I want to use.

    Is there anything I am missing... How can I possibly use this library of classes with the netbeans project that I am doing. (I have imported the jar file library this comes with)

    Thanks in advance.

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: Using Protected Methods, in a Java Library

    Typically the access modifier is set for a reason (see http://download.oracle.com/javase/tu...sscontrol.html)...so my guess is that these functions are not meant to be accessed in the way you want to. That being said, given the access levels you could extend the class and access the method from that child class

    Edit: This thread has been cross posted here:


    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    See http://www.javaprogrammingforums.com...s-posting.html

    Last edited by copeg; March 10th, 2011 at 05:06 PM.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Thanked 0 Times in 0 Posts

    Default Re: Using Protected Methods, in a Java Library

    So I make a class that extends the class with the protected method.
    And in the class that I'm doing all my image processing stuff I should make an instance of the extended class.
    Do you think I should do this?

    If I just put extend on the class I can access the method right?

    Oh and I didn't know about the cross posting, sorry wont do this again...

Similar Threads

  1. 2 Java methods and a sorting algorithm
    By Tiberius in forum Algorithms & Recursion
    Replies: 0
    Last Post: February 26th, 2011, 03:41 PM
  2. Replies: 0
    Last Post: May 3rd, 2010, 04:42 AM
  3. Novice with java methods, please help!
    By raidcomputer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 14th, 2009, 04:23 AM
  4. Replies: 2
    Last Post: June 13th, 2009, 01:44 AM
  5. Replies: 1
    Last Post: October 7th, 2008, 07:35 AM