#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0

    Post Help in actionevent


    can you help me what should i add to this program
    i want to view the joptionpane when i pressed alt+f1
    even if im focus in another window like browser please help

    Code:
    	private static JFrame frame;
    	public static void main(String[] args) throws Exception {
    		frame = new JFrame();
    		frame.addKeyListener(new KeyListener() {
    			@Override
    			public void keyTyped(KeyEvent e) {
    			}
    
    			@Override
    			public void keyReleased(KeyEvent e) {
    			}
    
    			@Override
    			public void keyPressed(KeyEvent e) {
    				if (e.isAltDown()) {
    					switch (e.getKeyCode()) {
    					case KeyEvent.VK_F1:
    						JOptionPane.showInputDialog("Queue");
    						break;
    					}
    				}
    			}
    		});
    		javax.swing.SwingUtilities.invokeLater(new Runnable() {
    			public void run() {
    
    				frame.setUndecorated(true);
    				frame.setVisible(true);
    			}
    		});
    	}
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    I don't know if you can steal events from another program using java.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    any other way that you can help me with my problem sir ..
    anyways thanks for the information ...
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    actually sir i get my idea in this code
    so can you help me to use this code in my project above

    Code:
    public class RobotExp {
    
    public static void main(String[] args) {
    
            try {
    
                Robot robot = new Robot();
                // Creates the delay of 5 sec so that you can open notepad before
                // Robot start writting
                robot.delay(5000);
                robot.keyPress(KeyEvent.VK_H);
                robot.keyPress(KeyEvent.VK_I);
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyPress(KeyEvent.VK_B);
                robot.keyPress(KeyEvent.VK_U);
                robot.keyPress(KeyEvent.VK_D);
                robot.keyPress(KeyEvent.VK_Y);
    
            } catch (AWTException e) {
                    e.printStackTrace();
                    System.out.print(e);
                }
            }
    }
    advance thanks for those who help ..
  8. #5
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    The code you posted with calls to Robot class methods will write characters, possibility to another program.

    What characters do you want to write?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by NormR
    What characters do you want to write?

    actually sir i want to use the ALT + F1
    when i pressed this key it show pop-up even im not focusing the program ... or even im using a browser when i pressed ALT +F1 it will show the pop-up ..
  12. #7
  13. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    not focusing the program
    I don't know if you can steal events from another program using java.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by NormR
    I don't know if you can steal events from another program using java.
    sir do you use system.in can you explain what is the use of system.in
  16. #9
  17. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    Have you read the API doc for the System class and for the in field in that class?
    Its explained there.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by NormR
    Have you read the API doc for the System class and for the in field in that class?
    Its explained there.
    sir do you read about robot in java it something like i use it to trace the keyboard input .... if you have read this can you give me some example sir because i starting reading this book ..

IMN logo majestic logo threadwatch logo seochat tools logo