Cloners :
|
|
Cloners :
|
|
Duplicate :
|
FULL PRODUCT VERSION : Java(TM) SE Runtime Environment (build 1.7.0_09-b05) ADDITIONAL OS VERSION INFORMATION : Mac OS X Lion (10.7.4) A DESCRIPTION OF THE PROBLEM : The entire application freezes when a drag is performed over a table with auto scroll enabled. From the attached stack trace it looks like a deadlock or livelock. REGRESSION. Regression from Apple's 6uX STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the snippet below. Drag the list (1,1,1) first over the table below and next around the entire screen. After the while entire application freezes and it is necessary to close the application. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - No problem should occur when dragging over a table. ACTUAL - The entire application freezes in a deadlock or livelock. ERROR MESSAGES/STACK TRACES THAT OCCUR : Stack trace from Event Dispatch thread: Thread [AWT-EventQueue-0] (Suspended) owns: Component$AWTTreeLock (id=39) owns: DropTarget$DropTargetAutoScroller (id=40) CMouseInfoPeer.nativeIsWindowUnderMouse(long) line: not available [native method] CMouseInfoPeer.isWindowUnderMouse(Window) line: 46 DragAndDropDemo$DndTable(Component).findUnderMouseInWindow(PointerInfo) line: 1325 DragAndDropDemo$DndTable(Component).getMousePosition() line: 1377 DragAndDropDemo$DndTable.autoscroll(Point) line: 92 DropTarget$DropTargetAutoScroller.actionPerformed(ActionEvent) line: 733 Timer.fireActionPerformed(ActionEvent) line: 312 Timer$DoPostEvent.run() line: 244 InvocationEvent.dispatch() line: 251 EventQueue.dispatchEventImpl(AWTEvent, Object) line: 721 EventQueue.access$200(EventQueue, AWTEvent, Object) line: 103 EventQueue$3.run() line: 682 EventQueue$3.run() line: 680 AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method] ProtectionDomain$1.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 76 EventQueue.dispatchEvent(AWTEvent) line: 691 EventDispatchThread.pumpOneEventForFilters(int) line: 244 EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 163 EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 151 EventDispatchThread.pumpEvents(int, Conditional) line: 147 EventDispatchThread.pumpEvents(Conditional) line: 139 EventDispatchThread.run() line: 97 REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.dnd.Autoscroll; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.DefaultListModel; import javax.swing.DropMode; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.TransferHandler; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; final class DragAndDropDemo extends JFrame { public DragAndDropDemo() { super("DnD Demo"); final DndTable table = new DndTable(new MyTableModel()); table.setDropMode(DropMode.INSERT_ROWS); table.setAutoscrolls(true); table.setTransferHandler(new TransferHandler() { @Override public boolean canImport(final TransferSupport support) { return true; } }); final DefaultListModel<String> model = new DefaultListModel<String>(); final JList<String> dragFromList = new JList<String>(model); dragFromList.setFocusable(false); dragFromList.setPrototypeCellValue(getDragFromContent(100)); model.insertElementAt(getDragFromContent(1), 0); dragFromList.setDragEnabled(true); dragFromList.setBorder(BorderFactory.createLoweredBevelBorder()); final JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); final JPanel wrap = new JPanel(); wrap.add(new JLabel("Drag from here:")); wrap.add(dragFromList); p.add(Box.createHorizontalStrut(4)); p.add(Box.createGlue()); p.add(wrap); p.add(Box.createGlue()); p.add(Box.createHorizontalStrut(4)); getContentPane().add(p, BorderLayout.NORTH); final JScrollPane sp = new JScrollPane(table); getContentPane().add(sp, BorderLayout.CENTER); getContentPane().setPreferredSize(new Dimension(260, 180)); } private static String getDragFromContent(final int count) { final StringBuffer buf = new StringBuffer(); for (int i = 0; i < 3; i++) { buf.append(String.valueOf(count)); buf.append(","); } buf.deleteCharAt(buf.length() - 1); return buf.toString(); } private static void createAndShowGUI() { final DragAndDropDemo test = new DragAndDropDemo(); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.pack(); test.setVisible(true); } public static void main(final String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private class DndTable extends JTable implements Autoscroll { DndTable(final TableModel dm) { super(dm); } public void autoscroll(final Point location) { getMousePosition(); } public Insets getAutoscrollInsets() { final int autoscrollMargin = 20; final Dimension size = getSize(); final Dimension size2 = DndTable.this.getSize(); final Rectangle rect = getVisibleRect(); final Insets autoscrollInsets = new Insets(0, 0, 0, 0); autoscrollInsets.top = rect.y + autoscrollMargin; autoscrollInsets.left = rect.x + autoscrollMargin; autoscrollInsets.bottom = size.height - (rect.y + rect.height) + autoscrollMargin; autoscrollInsets.right = size.width + size2.width - (rect.x + rect.width) + autoscrollMargin; return autoscrollInsets; } } private static class MyTableModel extends AbstractTableModel { private final Object[][] data = {{"Test0"}, {"Test1"}, {"Test2"}, {"Test3"}, {"Test4"}, {"Test5"}}; public int getColumnCount() { return 1; } public int getRowCount() { return data.length; } @Override public String getColumnName(final int col) { return "Column"; } public Object getValueAt(final int row, final int col) { return data[row][col]; } } } ---------- END SOURCE ----------
|