RFR: 7131166: SynthListUI / SynthInternalFrameTitlePane updateStyle() ignores method argument

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Jan 23 06:04:01 UTC 2023


On Sun, 22 Jan 2023 16:16:56 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> > As they ought to. All UI classes assume that the source for the property listener is the component it is the delegate for, which is why we see some classes passing e.getSource() and others passing the protected field. It's not something we can test, because the issues will arise when other people invoke the listener, and the JDK code doesn't (seem to) directly call it.
> 
> It is called to notify the listener since we add the UI delegate to the list: `list.addPropertyChangeListener(this);` in the SynthListUI.
> 
> It means that if the application/test will add `another UI delegate` to the list, then `updateStyle((JList)e.getSource());` will read the style from `another UI delegate`, not the current/protected field. It seems true that the code expects to always read the styles from the protected field, and that intention seems to be the opposite of what we do in the current change, no?

I have tried with a test where it is seen that **object for e.getSource() and "c" and "list" are sam**e so practically there is no functional change for this fix....Please suggest what else you want the test to do?


UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        JFrame frame = new JFrame();
        JList list = new JList();
        list.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            @Override
            public int getSize() { return strings.length; }
            @Override
            public Object getElementAt(int i) { return strings[i]; }
        });
        frame.getContentPane().add(list);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        list.addPropertyChangeListener(new PropertyChangeListener() {
             @Override
            public void propertyChange(PropertyChangeEvent evt) {
                    System.out.println("In test " + evt.getSource());

            }
        });
        list.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);


SynthListUI e.getSource _javax.swing.JList[,0,0,119x100,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder at 10aa41f2,flags=335
54728,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=DerivedColor
(color=57,105,138 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,selectionForeground=DerivedColor(color=255,255,255 par
ent=nimbusLightBackground offsets=0.0,0.0,0.0,0 pColor=255,255,255,visibleRowCount=8,layoutOrientation=0]_

SynthListUI c: _javax.swing.JList[,0,0,119x100,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder at 10aa41f2,flags=33554728,max
imumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=DerivedColor(color=57
,105,138 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,selectionForeground=DerivedColor(color=255,255,255 parent=nimbu
sLightBackground offsets=0.0,0.0,0.0,0 pColor=255,255,255,visibleRowCount=8,layoutOrientation=0]_

SynthListUI list: _javax.swing.JList[,0,0,119x100,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder at 10aa41f2,flags=33554728,
maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=DerivedColor(color
=57,105,138 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,selectionForeground=DerivedColor(color=255,255,255 parent=ni
mbusLightBackground offsets=0.0,0.0,0.0,0 pColor=255,255,255,visibleRowCount=8,layoutOrientation=0]_

In test _javax.swing.JList[,0,0,119x100,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder at 10aa41f2,flags=33554728,maximumSiz
e=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=DerivedColor(color=57,105,13
8 parent=nimbusSelectionBackground offsets=0.0,0.0,0.0,0 pColor=57,105,138,selectionForeground=DerivedColor(color=255,255,255 parent=nimbusLightB
ackground offsets=0.0,0.0,0.0,0 pColor=255,255,255,visibleRowCount=8,layoutOrientation=0]_

-------------

PR: https://git.openjdk.org/jdk/pull/11875



More information about the client-libs-dev mailing list