JPanel XOR Graphics Is Wrong Color After Scrolling A Combo-Box

Bug #1611180 reported by Aere Greenway
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openjdk-8 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Normally, XOR graphics in a JPanel works fine (and is the right color).

But if you open (expand) a combo-box, and scroll it, then select the item that was formerly selected, the next time you do XOR graphics in an adjacent JPanel, the color is wrong.

In this particular case, the color being XOR'ed is pure blue (0,0,255), but instead of blue, it appears on the screen as yellow. The graphics area background is white (255,255,255).

I expected the color of the XOR'ed note-head ellipse to be blue (as it was in openjdk-7), but it was instead yellow, but it only happens after scrolling a combo-box in an adjacent panel.

This problem appeared when Open Java 8 became the default JRE in Ubuntu. It happens in most (probably all) Ubuntu variants.

aere@Aere-Dell-Inspiron:~$ lsb_release -rd
Description: Ubuntu 16.04.1 LTS
Release: 16.04

Installed version: 8u91-b14-0ubuntu4~16.04.1

I will attach the source code of part of the application that does the XOR graphics, and in that file, the following method does the XOR graphics:

public void markNote(int keyOffset)

I will also attach a Debian package which will allow you to install a 30-day free-trial version of the KeyMusician Keyboard application, which will allow you to reproduce the problem.

To reproduce the problem:

1. Run the KeyMusician Keyboard application (you can use the default, pre-loaded soundfont of the Java Sound (Gervill) synthesizer).

2. When the music-staff is displayed, type some letter keys (or click with the mouse in the musical staff graphics display area. You should see round filled dots appear, whose color is blue. This is the expected behavior.

3. Click on the combo-box above the "ASSIGNABLE" slider, which opens the combo-box. Then use its scroll-bar to scroll it all the way to the bottom, and back to the top. Then re-select what was already selected ("modulation", in the default Linux configuration).

4. Type some letter-keys (or click in the musical staff graphics area). This time, the filled-circles (the note-heads) will be yellow. They will remain yellow, even if you iconify & restore the application window, or click on other tabbed panels (for the different function keys.

The method doing the XOR graphics is the following:

    public void markNote(int keyOffset)
    {
        System.out.println("(un)markNote(" + keyOffset + ")" + "external=" + isExternalNote) ;
        if (!isSetup && keyOffset >= 0 && keyOffset < NUM_KEYS)
        {
            dim = getSize() ;
            height = dim.getHeight() ;
            width = dim.getWidth() ;
            commonSetup() ;
            double markHeight = keyWidth ;
            double markWidth = keyWidth * 1.25 ;
            double y = height - (keyOffset + 1) * keyWidth ;
            double x = shortLineStart + (shortLineLength / 2) - (markWidth / 2) ;
            System.out.println("markNote " + x + "," + y) ;
            System.out.println("BG=" + g2.getBackground() + ", FG=" + g2.getPaint() + ", newBG=" + backGround + ", newFG=" + foreGround) ; // TEMPORARY
            g2.setXORMode(backGround) ;
            g2.setColor(foreGround) ;
            if (isExternalNote)
            {
                g2.setPaint(KEY_MARK_COLOR_EXTERNAL) ;
            }
            else
            {
// g2.setPaint(KEY_MARK_COLOR) ;
                g2.setPaint(Color.BLUE) ;
            }
            Ellipse2D.Double mark = new Ellipse2D.Double(x, y, markWidth, markHeight) ;
            g2.fill(mark) ;
            System.out.println("Color=" + g2.getPaint()) ; // TEMPORARY
            g2.setPaintMode() ;
        }
    }

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: openjdk-8-jre 8u91-b14-0ubuntu4~16.04.1
ProcVersionSignature: Ubuntu 4.4.0-31.50-generic 4.4.13
Uname: Linux 4.4.0-31-generic i686
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: i386
CurrentDesktop: LXDE
Date: Mon Aug 8 19:45:42 2016
InstallationDate: Installed on 2013-05-18 (1178 days ago)
InstallationMedia: Lubuntu 13.04 "Raring Ringtail" - Release i386 (20130423.1)
SourcePackage: openjdk-8
UpgradeStatus: Upgraded to xenial on 2016-07-22 (18 days ago)

Revision history for this message
Aere Greenway (aere) wrote :
Revision history for this message
Aere Greenway (aere) wrote :

On the surface, this error report may appear quite bizarre, but I have spent a lot of time narrowing-down the conditions that trigger the problem.

Since Ubuntu 16.04 came out in April, I have been seeing the yellow notes, but have been unable to identify what triggered them. I finally spent a lot of time trying to narrow down the trigger, and this is what I have come up with.

A few additional points may be useful to consider:

1. You have to actually scroll the combo-box. If you just expand the combo-box, and select anything within the range displayed, the problem does not occur.

2. Even if you scroll a combo-box in another pane (such as the "F1 Help / Setup" pane's "Configuration Files" combo-box), it will affect all the other tabbed-panes.

3. Although the "Instrument" combo-box being scrolled will trigger the problem on many machines, it would not trigger the problem on all of my test machines. Only the "ASSIGNABLE" slider's combo-box (and the "Configuration Files" combo-box on the "F1" pane) will trigger the problem on all of my test machines.

4. Although the "ASSIGNABLE" slider's combo-box has both an Action-Performed and State-Change listener, the only action taken by those listeners is to log the event using System.out.println(). The configuration files combo-box, on the other hand, has a lot of side-effects.

5. It may seem far-fetched that a component in a separate panel can affect the graphics in an adjacent panel, but I can point out cases you can reproduce (bugs I have been living with for a long time without reporting) where this is definitely the case. For instance, if you hit a key to produce a note immediately to the left of one of sliders (holding it down so the dot remains displayed), and while doing so, manipulate the slider to the right of the note using the mouse, the note-dot gets erased, even though the key producing the note is left down (and the note's sound continues audibly). This problem has been observed in openjdk-7, and on Oracle Java as well. I can submit a problem report for that if you wish.

I will attached a text-file containing the System.out.println() entries in the area where the problem occurred. I did not observe anything out of the ordinary for cases with the yellow notes.

Revision history for this message
Aere Greenway (aere) wrote :

A text-file of the debug-trace (information logged using System.out.println()) has been attached.

The problem area is toward the very end. You can see where I scrolled (and selected an item in the assignable combo-box in the trace entry:

jComboBoxF2Assign.itemStateChanged, event=java.awt.event.ItemEvent[ITEM_STATE_CHANGED,item=8-Balance,stateChange=DESELECTED] on javax.swing.JComboBox[,0,201,299x28,layout=javax.swing.plaf.basic.BasicComboBoxUI$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.synth.SynthBorder@1970b64,flags=328,maximumSize=java.awt.Dimension[width=32767,height=32],minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=8-Balance]

The note played before doing that was displayed blue, and the note played after doing that was displayed yellow.

Revision history for this message
Aere Greenway (aere) wrote :

I have attached the code that does the JPanel graphics display.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.