author | psadhukhan |
Thu, 16 Aug 2018 11:15:22 +0530 | |
changeset 51908 | 3ba3d39b91c7 |
permissions | -rw-r--r-- |
51908
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
1 |
/* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
4 |
* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
8 |
* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
13 |
* accompanied this code). |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
14 |
* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
18 |
* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
21 |
* questions. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
22 |
*/ |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
23 |
/* |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
24 |
* @test |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
25 |
* @key headful |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
26 |
* @bug 8202702 |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
27 |
* @summary Verifies if Jtable clear selction causes disappearance of a row. |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
28 |
* @run main/manual TestClearSel |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
29 |
*/ |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
30 |
import java.awt.BorderLayout; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
31 |
import java.awt.Component; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
32 |
import java.awt.FlowLayout; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
33 |
import java.awt.event.MouseAdapter; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
34 |
import java.awt.event.MouseEvent; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
35 |
import java.util.concurrent.CountDownLatch; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
36 |
import java.util.concurrent.TimeUnit; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
37 |
import javax.swing.JButton; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
38 |
import javax.swing.JDialog; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
39 |
import javax.swing.JFrame; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
40 |
import javax.swing.JPanel; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
41 |
import javax.swing.JTable; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
42 |
import javax.swing.JTextArea; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
43 |
import javax.swing.SwingUtilities; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
44 |
import javax.swing.table.DefaultTableModel; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
45 |
import javax.swing.table.TableModel; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
46 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
47 |
public class TestClearSel { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
48 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
49 |
static DefaultTableModel model; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
50 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
51 |
public static void main(String[] args) throws Exception { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
52 |
final CountDownLatch latch = new CountDownLatch(1); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
53 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
54 |
ClearSelTest test = new ClearSelTest(latch); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
55 |
Thread T1 = new Thread(test); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
56 |
T1.start(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
57 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
58 |
// wait for latch to complete |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
59 |
boolean ret = false; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
60 |
try { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
61 |
ret = latch.await(60, TimeUnit.SECONDS); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
62 |
} catch (InterruptedException ie) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
63 |
throw ie; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
64 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
65 |
if (!ret) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
66 |
test.dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
67 |
throw new RuntimeException(" User has not executed the test"); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
68 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
69 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
70 |
if (test.testResult == false) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
71 |
throw new RuntimeException("Some text were not rendered properly" |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
72 |
+ " during painting of Jtable rows "); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
73 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
74 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
75 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
76 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
77 |
class ClearSelTest implements Runnable { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
78 |
static JFrame f; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
79 |
static JDialog dialog; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
80 |
static DefaultTableModel model; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
81 |
public boolean testResult = false; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
82 |
private final CountDownLatch latch; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
83 |
private static String[] rows = new String[]{ |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
84 |
"Row1", "Row2", "Row3", "Row4", "Row5", |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
85 |
"Row6", "Row7", "Row8", "Row9", "Row10"}; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
86 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
87 |
public ClearSelTest(CountDownLatch latch) throws Exception { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
88 |
this.latch = latch; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
89 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
90 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
91 |
@Override |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
92 |
public void run() { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
93 |
try { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
94 |
SwingUtilities.invokeAndWait(() -> { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
95 |
createUI(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
96 |
clearSelTest(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
97 |
}); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
98 |
} catch (Exception ex) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
99 |
if (f != null) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
100 |
f.dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
101 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
102 |
latch.countDown(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
103 |
throw new RuntimeException("createUI Failed: " + ex.getMessage()); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
104 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
105 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
106 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
107 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
108 |
public void dispose() { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
109 |
dialog.dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
110 |
f.dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
111 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
112 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
113 |
private static void clearSelTest() { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
114 |
final DefaultTableModel model = new DefaultTableModel(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
115 |
model.addColumn("Test", rows); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
116 |
final JTable table = new JTable(model); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
117 |
table.setRowHeight(25); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
118 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
119 |
final MouseAdapter adapt = new MouseAdapter() { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
120 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
121 |
@Override |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
122 |
public void mouseMoved(final MouseEvent pE) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
123 |
final int row = table.rowAtPoint(pE.getPoint()); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
124 |
if (row > -1) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
125 |
table.setRowSelectionInterval(row, row); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
126 |
} else { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
127 |
table.clearSelection(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
128 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
129 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
130 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
131 |
@Override |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
132 |
public void mouseEntered(final MouseEvent pE) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
133 |
final int row = table.rowAtPoint(pE.getPoint()); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
134 |
if (row > -1) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
135 |
table.setRowSelectionInterval(row, row); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
136 |
} else { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
137 |
table.clearSelection(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
138 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
139 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
140 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
141 |
@Override |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
142 |
public void mouseExited(final MouseEvent pE) { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
143 |
table.clearSelection(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
144 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
145 |
}; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
146 |
table.addMouseListener(adapt); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
147 |
table.addMouseMotionListener(adapt); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
148 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
149 |
f = new JFrame(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
150 |
f.setSize(300, 300); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
151 |
f.setLocationRelativeTo(null); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
152 |
f.add(table); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
153 |
f.setVisible(true); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
154 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
155 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
156 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
157 |
private final void createUI() { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
158 |
String description |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
159 |
= " INSTRUCTIONS:\n" |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
160 |
+ " A JTable will be shown.\n" |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
161 |
+ " Move mouse over different row to select the row.\n " |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
162 |
+ " Please verify if row text disappear " |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
163 |
+ " if mouse is moved out of table.\n" |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
164 |
+ " If any moment any part of the rows will not be\n " |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
165 |
+ " painted properly and if some text are missing in JTable,\n " |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
166 |
+ " then press fail else press pass"; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
167 |
|
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
168 |
dialog = new JDialog(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
169 |
dialog.setTitle("textselectionTest"); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
170 |
JTextArea textArea = new JTextArea(description); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
171 |
textArea.setEditable(false); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
172 |
final JButton passButton = new JButton("PASS"); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
173 |
passButton.addActionListener((e) -> { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
174 |
testResult = true; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
175 |
dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
176 |
latch.countDown(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
177 |
}); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
178 |
final JButton failButton = new JButton("FAIL"); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
179 |
failButton.addActionListener((e) -> { |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
180 |
testResult = false; |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
181 |
dispose(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
182 |
latch.countDown(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
183 |
}); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
184 |
JPanel mainPanel = new JPanel(new BorderLayout()); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
185 |
mainPanel.add(textArea, BorderLayout.CENTER); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
186 |
JPanel buttonPanel = new JPanel(new FlowLayout()); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
187 |
buttonPanel.add(passButton); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
188 |
buttonPanel.add(failButton); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
189 |
mainPanel.add(buttonPanel, BorderLayout.SOUTH); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
190 |
dialog.add(mainPanel); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
191 |
dialog.pack(); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
192 |
dialog.setVisible(true); |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
193 |
} |
3ba3d39b91c7
8202702: Clearing selection on JTable causes disappearance of a row
psadhukhan
parents:
diff
changeset
|
194 |
} |