Package org.fest.swing.fixture
Interface KeyboardInputSimulationFixture
- All Known Subinterfaces:
CommonComponentFixture
- All Known Implementing Classes:
DialogFixture,FrameFixture,GenericComponentFixture,JButtonFixture,JCheckBoxFixture,JComboBoxFixture,JFileChooserFixture,JInternalFrameFixture,JLabelFixture,JListFixture,JMenuItemFixture,JOptionPaneFixture,JPanelFixture,JPopupMenuFixture,JRadioButtonFixture,JScrollBarFixture,JScrollPaneFixture,JSliderFixture,JSpinnerFixture,JSplitPaneFixture,JTabbedPaneFixture,JTableFixture,JTextComponentFixture,JToggleButtonFixture,JToolBarFixture,JTreeFixture,WindowFixture
public interface KeyboardInputSimulationFixture
Understands simulation of keyboard input on a GUI component.
-
Method Summary
Modifier and TypeMethodDescriptionpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's GUI component.pressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's GUI component.pressKey(int keyCode) Simulates a user pressing given key on this fixture's GUI component.releaseKey(int keyCode) Simulates a user releasing the given key on this fixture's GUI component.
-
Method Details
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's GUI component.- Parameters:
keyCodes- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given array of codes isnull.IllegalArgumentException- if any of the given code is not a valid key code.IllegalStateException- if the component is disabled.IllegalStateException- if the component is not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing given key on this fixture's GUI component.- Parameters:
keyCode- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalArgumentException- if the given code is not a valid key code.IllegalStateException- if the component is disabled.IllegalStateException- if the component is not showing on the screen.- See Also:
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's GUI component. Modifiers is a mask from the availablemasks.InputEventThe following code listing shows how to press 'CTRL' + 'C' in a platform-safe way:
JTextComponentFixture textBox = dialog.textBox("username"); textBox.selectAll() .pressAndReleaseKey(key().modifiers(VK_CcontrolOrCommandMask()));- Parameters:
keyPressInfo- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenKeyPressInfoisnull.IllegalArgumentException- if the given code is not a valid key code.IllegalStateException- if the component is disabled.IllegalStateException- if the component is not showing on the screen.
-
releaseKey
Simulates a user releasing the given key on this fixture's GUI component.- Parameters:
keyCode- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalArgumentException- if the given code is not a valid key code.IllegalStateException- if the component is disabled.IllegalStateException- if the component is not showing on the screen.- See Also:
-