This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 190167 - "No Border" should not map to setBorder(null)
Summary: "No Border" should not map to setBorder(null)
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Other
: P4 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 194927 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-06 02:36 UTC by _ gtzabari
Modified: 2015-03-18 15:11 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2010-09-06 02:36:07 UTC
According to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4143601 setBorder(null) means the L&F can decide apply any border it wishes. "No border" should map to EmptyBorder(0, 0, 0, 0).
Comment 1 _ gtzabari 2010-09-06 02:37:03 UTC
If you apply "no border" to a JTable inside a JScrollPane Netbeans will setBorder(null) and you will notice the border does not get removed. Using EmptyBorder(0, 0, 0, 0) works just fine.
Comment 2 Jan Stola 2011-10-20 13:41:07 UTC
I don't agree with that. Usage of empty border to enforce no border is a workaround for some special/problematic situations and it should not be the default approach.

In fact, it is just an implementation detail that setting of null border doesn't work in the mentioned case while setting of empty border works.

The official documention (of JComponent.setBorder()) says:

"Although technically you can set the border on any object that inherits from JComponent, the look and feel implementation of many standard Swing components doesn't work well with user-set borders. In general, when you want to set a border on a standard Swing component other than JPanel or JLabel, we recommend that you put the component in a JPanel and set the border on the JPanel."

Hence, there is no guarantee that even empty border will not be overriden for component different from JLabel and JPanel. On the other hand, for the only components for which this method is guaranteed to work (JLabel and JPanel) it is perfectly fine to use null.
Comment 3 _ gtzabari 2011-10-20 17:30:20 UTC
Jan,

My interpretation of "doesn't work well" in "[...] the look and feel implementation of many standard Swing components doesn't work well with user-set borders" is that it won't look nice. I am not aware of any L&F implementation that overrides an empty border. Are you?

On the other hand, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4143601 specifically states that setBorder(null) *is* meant to be overridden by L&Fs.

You could be perfectly right about empty borders being overridden, but we should have concrete proof of this. Can you perhaps ask someone in the Swing team for a clarification?
Comment 4 Jan Stola 2011-11-04 09:07:53 UTC
*** Bug 194927 has been marked as a duplicate of this bug. ***
Comment 5 _ gtzabari 2012-01-04 22:41:22 UTC
Reopening this issue.

1. Jan's interpretation disagrees with the BugParade evaluation which reads:

"L&Fs are only allowed to remove/replace borders and colors which meet one of two criteria.  If they are set to null, or if the instance returned from the "get" method implements the UIResource interface."

Please request feedback/clarification from additional sources (ideally from the Swing team).

2. Regardless of which interpretation is right, the fact of the matter is that Netbeans does the wrong thing when the user sets a border on a JTable inside a JScrollPane. This should be fixed.

The "right thing" would be to allow users to set the border in the visual editor and do whatever is necessary under-the-hood for it to look right. The current behavior is pushing implementation details on end-users.