This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
8259237: Demo selection changes with left/right arrow key. No need to press space for selection. #99
Closed
Closed
8259237: Demo selection changes with left/right arrow key. No need to press space for selection. #99
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
903ffcb
8259237: Demo selection changes with left/right arrow key. No need to…
pankaj-bansal 724f599
Remove duplicate call to remove listener
pankaj-bansal de3db58
Remove duplicate code for AquaL&F
pankaj-bansal 6c74560
Add current bugid
pankaj-bansal fca7f7a
Update Spec
pankaj-bansal 9962d61
Add checkbox in test
pankaj-bansal File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,15 @@ | |
/* | ||
* @test | ||
* @key headful | ||
* @bug 8249548 | ||
* @bug 8249548 8259237 | ||
* @summary Test focus traversal in button group containing JToggleButton | ||
* and JRadioButton | ||
* @run main TestButtonGroupFocusTraversal | ||
*/ | ||
|
||
import javax.swing.AbstractAction; | ||
import javax.swing.ButtonGroup; | ||
import javax.swing.JCheckBox; | ||
import javax.swing.JFrame; | ||
import javax.swing.JRadioButton; | ||
import javax.swing.JTextField; | ||
|
@@ -43,12 +45,16 @@ | |
import java.awt.KeyboardFocusManager; | ||
import java.awt.Point; | ||
import java.awt.Robot; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.KeyEvent; | ||
|
||
public class TestButtonGroupFocusTraversal { | ||
private static JFrame frame; | ||
private static JTextField textFieldFirst, textFieldLast; | ||
private static JToggleButton toggleButton1, toggleButton2; | ||
private static JCheckBox checkBox1, checkBox2; | ||
private static boolean toggleButtonActionPerformed; | ||
private static boolean checkboxActionPerformed; | ||
private static JRadioButton radioButton1, radioButton2; | ||
private static Robot robot; | ||
|
||
|
@@ -75,6 +81,36 @@ public void run() { | |
toggleButton2 = new JToggleButton("2"); | ||
radioButton1 = new JRadioButton("1"); | ||
radioButton2 = new JRadioButton("2"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to be safe please check the JCheckBox, it also extends the JToggleButton and we should not break it. |
||
checkBox1 = new JCheckBox("1"); | ||
checkBox2 = new JCheckBox("2"); | ||
|
||
toggleButton1.setAction(new AbstractAction() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
toggleButtonActionPerformed = true; | ||
} | ||
}); | ||
|
||
toggleButton2.setAction(new AbstractAction() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
toggleButtonActionPerformed = true; | ||
} | ||
}); | ||
|
||
checkBox1.setAction(new AbstractAction() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
checkboxActionPerformed = true; | ||
} | ||
}); | ||
|
||
checkBox2.setAction(new AbstractAction() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
checkboxActionPerformed = true; | ||
} | ||
}); | ||
|
||
ButtonGroup toggleGroup = new ButtonGroup(); | ||
toggleGroup.add(toggleButton1); | ||
|
@@ -84,8 +120,13 @@ public void run() { | |
radioGroup.add(radioButton1); | ||
radioGroup.add(radioButton2); | ||
|
||
ButtonGroup checkboxButtonGroup = new ButtonGroup(); | ||
checkboxButtonGroup.add(checkBox1); | ||
checkboxButtonGroup.add(checkBox2); | ||
|
||
toggleButton2.setSelected(true); | ||
radioButton2.setSelected(true); | ||
checkBox2.setSelected(true); | ||
|
||
frame = new JFrame("Test"); | ||
frame.setLayout(new FlowLayout()); | ||
|
@@ -96,6 +137,8 @@ public void run() { | |
pane.add(toggleButton2); | ||
pane.add(radioButton1); | ||
pane.add(radioButton2); | ||
pane.add(checkBox1); | ||
pane.add(checkBox2); | ||
pane.add(textFieldLast); | ||
|
||
frame.pack(); | ||
|
@@ -127,6 +170,20 @@ private static void checkFocusedComponent (Component component) { | |
} | ||
} | ||
|
||
private static void checkToggleButtonActionPerformed() { | ||
if (toggleButtonActionPerformed) { | ||
throw new RuntimeException("Toggle Button Action should not be" + | ||
"performed"); | ||
} | ||
} | ||
|
||
private static void checkCheckboxActionPerformed() { | ||
if (toggleButtonActionPerformed) { | ||
throw new RuntimeException("Checkbox Action should not be" + | ||
"performed"); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
robot = new Robot(); | ||
robot.setAutoDelay(100); | ||
|
@@ -164,9 +221,15 @@ public static void main(String[] args) throws Exception { | |
pressKey(KeyEvent.VK_TAB); | ||
checkFocusedComponent(radioButton2); | ||
|
||
pressKey(KeyEvent.VK_TAB); | ||
checkFocusedComponent(checkBox2); | ||
|
||
pressKey(KeyEvent.VK_TAB); | ||
checkFocusedComponent(textFieldLast); | ||
|
||
pressKey(KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); | ||
checkFocusedComponent(checkBox2); | ||
|
||
pressKey(KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); | ||
checkFocusedComponent(radioButton2); | ||
|
||
|
@@ -181,15 +244,19 @@ public static void main(String[] args) throws Exception { | |
|
||
pressKey(KeyEvent.VK_LEFT); | ||
checkFocusedComponent(toggleButton1); | ||
checkToggleButtonActionPerformed(); | ||
|
||
pressKey(KeyEvent.VK_RIGHT); | ||
checkFocusedComponent(toggleButton2); | ||
checkToggleButtonActionPerformed(); | ||
|
||
pressKey(KeyEvent.VK_UP); | ||
checkFocusedComponent(toggleButton1); | ||
checkToggleButtonActionPerformed(); | ||
|
||
pressKey(KeyEvent.VK_DOWN); | ||
checkFocusedComponent(toggleButton2); | ||
checkToggleButtonActionPerformed(); | ||
|
||
pressKey(KeyEvent.VK_TAB); | ||
checkFocusedComponent(radioButton2); | ||
|
@@ -206,6 +273,24 @@ public static void main(String[] args) throws Exception { | |
pressKey(KeyEvent.VK_DOWN); | ||
checkFocusedComponent(radioButton2); | ||
|
||
pressKey(KeyEvent.VK_TAB); | ||
checkFocusedComponent(checkBox2); | ||
|
||
pressKey(KeyEvent.VK_LEFT); | ||
checkCheckboxActionPerformed(); | ||
checkFocusedComponent(checkBox1); | ||
|
||
pressKey(KeyEvent.VK_RIGHT); | ||
checkCheckboxActionPerformed(); | ||
checkFocusedComponent(checkBox2); | ||
|
||
pressKey(KeyEvent.VK_UP); | ||
checkCheckboxActionPerformed(); | ||
checkFocusedComponent(checkBox1); | ||
|
||
pressKey(KeyEvent.VK_DOWN); | ||
checkCheckboxActionPerformed(); | ||
checkFocusedComponent(checkBox2); | ||
} finally { | ||
if (frame != null) { | ||
SwingUtilities.invokeAndWait(frame::dispose); | ||
|
@@ -214,4 +299,3 @@ public static void main(String[] args) throws Exception { | |
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to append this bugid as product code is changed for which this testcase is modified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please have a look.