Is there a way to do a keyevent while a joptionpane.inputdialog is open?
I dont want a keyevent to happen before a inputdialog is open or after, I want a keyevent to happen exactly while the inputdialog is open
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Is there a way to do a keyevent while a joptionpane.inputdialog is open?
I dont want a keyevent to happen before a inputdialog is open or after, I want a keyevent to happen exactly while the inputdialog is open
Can you make a small, complete program that compiles, executes and shows the problem.
I don't know what events can happen when a modal dialog is open.
If you want a non-modal window, use the JDialog class.
If you don't understand my answer, don't ignore it, ask a question.
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
public class key {
public static void main(String[]args) throws AWTException{
final Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_X);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_X);
String area = JOptionPane.showInputDialog("");
}
}
Here does the keyevent happened before the input dialog shows, I want the keyevent to happen when the input dialog is open.
You will need to use threads if you want the Robot methods to happen when the JOption pane is open. Not sure what the timing requirement will be to get the event to happen after the dialog is shown.
Please edit your post and wrap your code with code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.