JDK-4305789 : BasicToolBarUI: Request conversion of private instance variable
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2000-01-20
  • Updated: 2022-09-27
Description

Name: skT88420			Date: 01/19/2000


E:\LocalCVSRepository\SourceCode\JBuilder\Mockup\RenderablePipelineClasses>java
-version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)


I have run into a problem with the definition of the following instance
variable:

private Container dockingSource;

in the javax.swing.plaf.basic.BasicToolBarUI class. Specifically, I wanted
to add the functionality to dock the toolbar to any instantiated JFrame
within an application instead of just the original JFrame containing the
toolbar. I have accomplished this successfully, but unfortunately, the
private access modifer on the dockingSource instance variable has forced me
to include a large portion of the BasicToolBarUI code within a custom UI
class. If the dockingSource variable were changed to protected 
or public get/set accessors were provided , I could easily change what it
references within my derived UI class without necessitating its replacement
with my own dockingSource variable and replacement of all the methods that
depend upon it which include:

dragTo
floatAt
setFloating

and the private methods

getDockingConstraint
mapConstraintToOrientation

which the dragTo, etc. methods depend upon.

I am requesting that the access modifier for dockingSource be changed to:

protected Container dockingSource

OR

that protected or public get/set accessors be provided for this instance
variable.
(Review ID: 100123) 
======================================================================

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10309 Date: 2022-09-16 13:47:41 +0000
27-09-2022

WORK AROUND Name: skT88420 Date: 01/19/2000 See description section. ====================================================================== Rather than reimplementing the UI, one could use reflection to get the field and call setAccessible(true) on it. This is admittedly an ugly hack. ###@###.### 2001-11-14
14-11-2001

EVALUATION This should be fixed. ###@###.### 2001-11-14
14-11-2001