Results 1 to 2 of 2
Thread: Border vs BorderFactory
- 08-01-2012, 12:55 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Border vs BorderFactory
At first blush, it appears that Border and BorderFactory do essentially the same thing. Most of the examples I have seen use BorderFactory, but why would I want to use one or the other? Did BorderFactory correct a shortcoming in Border or vice versa? "Enquiring Minds Want To Know!"
- 08-01-2012, 01:55 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Re: Border vs BorderFactory
BorderFactory creates Borders, (Border is an interface, BorderFactory a class), thus they are quite different.At first blush, it appears that Border and BorderFactory do essentially the same thing
It is a Factory class, having convenient methods for creating Borders. This is opposed to having to know the ins and outs of all the Border implementations (BevelBorder, LineBorder, etc...). Further, encapsulating the creation of these class through a Factory class allows the Factory to create and reuse instances of an object (this isn't true for all the methods of BorderFactory, but as the API states: "Wherever possible, this factory will hand out references to shared Border instances.").why would I want to use one or the other?
If you don't know what a Factory class is, you might wish to study up on the Factory design pattern: Factory method pattern - Wikipedia, the free encyclopedia
Similar Threads
-
BorderFactory.createTitledBorder [Need Help!!!]
By baobao816 in forum AWT / SwingReplies: 1Last Post: 03-16-2012, 04:20 PM -
Set border
By anilkumar_vist in forum New To JavaReplies: 1Last Post: 02-06-2010, 11:25 AM -
how can create border
By yuen in forum AWT / SwingReplies: 6Last Post: 11-08-2009, 11:42 AM -
Border with LestCellRenderer
By Gajesh Tripathi in forum AWT / SwingReplies: 5Last Post: 06-02-2009, 06:59 AM -
BorderFactory to set position?
By aleplgr in forum AWT / SwingReplies: 2Last Post: 01-30-2008, 12:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks