How come the AbstractBorder class is abstract?
It implements, I think, all the methods from the interface Border. Yet it's abstract. How is that possible? I thought that in java an abstract class had to have at least one abstract method. I was trying to make my own AbstractBorder subclass and was looking at the AbstractBorder class when I noticed this.
Re: How come the AbstractBorder class is abstract?
Please test all of your assumptions by putting together an SSCCE.
Re: How come the AbstractBorder class is abstract?
An SSCEE? I was asking pretty much how a class could be abstract without any abstract methods or unimplemented interface methods.
Also, another thing, I can sub that class so far and only have some of its methods and yet I don't get that "It's abstract" bla bla bla error message.
I checked and my subclass isn't abstract by default even if I had no methods in it.
How can javax.swing.border.AbstractBorder be abstract and yet I have a subclass called MyBorder that has no methods in it and isn't abstract?
It's a direct subclass in case you're wondering.
I do see that the AbstractBorder class is a skeleton of sorts as it returns like default values and doesn't really do that much.
Re: How come the AbstractBorder class is abstract?
Quote:
I was asking pretty much how a class could be abstract without any abstract methods or unimplemented interface methods.
...
How can javax.swing.border.AbstractBorder be abstract and yet I have a subclass called MyBorder that has no methods in it and isn't abstract?
To quote the API for AbstractBorder:
Quote:
This provides a convenient base class from which other border classes can be easily derived.
And to quote the Oracle description on Abstract classes
Quote:
An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
A class is declared abstract because it lacks some type of implementation. In the case of AbstractBorder, it's does no painting and and has insets of size 0 - this default behavior is meant to be overriden/implemented
Re: How come the AbstractBorder class is abstract?
Quote:
Originally Posted by
javapenguin
An SSCEE? I was asking pretty much how a class could be abstract without any abstract methods or unimplemented interface methods.
Yes, an SSCCE. Had you simply tested your assumptions first by throwing together a little test program, you could have answered your own question.
Re: How come the AbstractBorder class is abstract?
I did have such a test program. However, the results, which did point at what copeg was saying, conflicted with that I had long believed to be true about abstract, that is that I thought I needed at least one abstract method. Now I know otherwise.