-
Bug
-
Resolution: Duplicate
-
P4
-
7
-
generic
-
linux
SYNOPSIS
--------
Problems with Button's color when using DnD operations
OPERATING SYSTEM
----------------
Linux (tested with RedHat Linux 5 Server and Ubuntu 10.04)
FULL JDK VERSIONS
-----------------
Java 7 (GA - b147)
Java 6 (1.6.0_26)
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
We have found several problems with buttons that employ DnD operations. The problems only occur with XAWT.
By default, normal Button colour is light grey. If it's pressed, the colour changes to dark grey, for visual feedback.
The attached testcase shows that when the button has a drag feature, its colour changes to dark grey during the drag operation, but does not correctly change back to light grey afterwards. When dropping an item onto the button its internal colour setting changes to light grey, but the button's colour on the screen does not change completely (it looks as though it isn't repainted properly).
When focus is then moved to the window containing the button, the button's colour changes back to light grey but it still appears to be in the depressed state, which is incorrect.
TESTCASE
--------
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.beans.*;
public class DragButtonTest extends Frame implements DragGestureListener, Transferable {
private String data = null;
private static DataFlavor flavors[] = {DataFlavor.stringFlavor};
public DragButtonTest(String s){
this.data = s;
setTitle("Drag Source : "+s);
Button button = new Button(s);
setLayout(new GridLayout(0,1));
add(button);
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(button, DnDConstants.ACTION_COPY, this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
pack();
setSize(300,100);
setVisible(true);
}
public void dragGestureRecognized(DragGestureEvent dge){
dge.startDrag(null, this);
}
public synchronized DataFlavor[] getTransferDataFlavors(){
return flavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor){
return(flavor.equals(flavors[0]));
}
public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(flavors[0])) return(Object)data;
throw new UnsupportedFlavorException(flavor);
}
public static void main(String args[]){
for (String s : args) new DragButtonTest(s);
}
}
REPRODUCTION INSTRUCTIONS
-------------------------
Note: these instructions apply to Gnome.
1. Start gedit
2. Compile and run test program with argument "abc":
$ java DragButtonTest abc
3. Click and drag the "abc" button from "Drag Source" window and drop it
into the gedit window (the button's colour should have changed to
dark grey. If not, please try again.).
4. Select "abc" in the gedit window, then drag it and drop it into the
"Drag Source" window. Note that the button colour does not change
(bug)
5. "Drag Source" window does not accept drop action
6. Select "abc" in the gedit window, then drag it and drop it into the
"Drag Source" window again. Note that the button's colour is
partially changed to light gray. It doesn't seem to be repainted
properly (bug)
7. Click on the title bar of the "Drag Source" window to move the focus
to it (do not click the button). Note that the button's colou changes
to light gray, but the edges of the button indicate that it is still
depressed - if you click the button it returns to its unpressed
state.
--------
Problems with Button's color when using DnD operations
OPERATING SYSTEM
----------------
Linux (tested with RedHat Linux 5 Server and Ubuntu 10.04)
FULL JDK VERSIONS
-----------------
Java 7 (GA - b147)
Java 6 (1.6.0_26)
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
We have found several problems with buttons that employ DnD operations. The problems only occur with XAWT.
By default, normal Button colour is light grey. If it's pressed, the colour changes to dark grey, for visual feedback.
The attached testcase shows that when the button has a drag feature, its colour changes to dark grey during the drag operation, but does not correctly change back to light grey afterwards. When dropping an item onto the button its internal colour setting changes to light grey, but the button's colour on the screen does not change completely (it looks as though it isn't repainted properly).
When focus is then moved to the window containing the button, the button's colour changes back to light grey but it still appears to be in the depressed state, which is incorrect.
TESTCASE
--------
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.beans.*;
public class DragButtonTest extends Frame implements DragGestureListener, Transferable {
private String data = null;
private static DataFlavor flavors[] = {DataFlavor.stringFlavor};
public DragButtonTest(String s){
this.data = s;
setTitle("Drag Source : "+s);
Button button = new Button(s);
setLayout(new GridLayout(0,1));
add(button);
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(button, DnDConstants.ACTION_COPY, this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
pack();
setSize(300,100);
setVisible(true);
}
public void dragGestureRecognized(DragGestureEvent dge){
dge.startDrag(null, this);
}
public synchronized DataFlavor[] getTransferDataFlavors(){
return flavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor){
return(flavor.equals(flavors[0]));
}
public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(flavors[0])) return(Object)data;
throw new UnsupportedFlavorException(flavor);
}
public static void main(String args[]){
for (String s : args) new DragButtonTest(s);
}
}
REPRODUCTION INSTRUCTIONS
-------------------------
Note: these instructions apply to Gnome.
1. Start gedit
2. Compile and run test program with argument "abc":
$ java DragButtonTest abc
3. Click and drag the "abc" button from "Drag Source" window and drop it
into the gedit window (the button's colour should have changed to
dark grey. If not, please try again.).
4. Select "abc" in the gedit window, then drag it and drop it into the
"Drag Source" window. Note that the button colour does not change
(bug)
5. "Drag Source" window does not accept drop action
6. Select "abc" in the gedit window, then drag it and drop it into the
"Drag Source" window again. Note that the button's colour is
partially changed to light gray. It doesn't seem to be repainted
properly (bug)
7. Click on the title bar of the "Drag Source" window to move the focus
to it (do not click the button). Note that the button's colou changes
to light gray, but the edges of the button indicate that it is still
depressed - if you click the button it returns to its unpressed
state.
- duplicates
-
JDK-6295043 Drag source button remains pressed state after dnd
-
- Open
-