1

how can I upload another frame (when i am running on my frame) by press CTRL+SPACE?

I mean , I am on the main frame, and I want that by push CTRL+SPACE in the keyboard, another frame will coming up.

i've tried some things but I just found the option with ALT + 'key' (mnemonic) but Iwant CTRL + SPACE


this.addKeyListener(new KeyAdapter() { 
    public void keyPressed(KeyEvent ev) { 
        if(ev.getKeyCode() == KeyEvent.VK_CONTROL + KeyEvent.VK_SPACE){ 
            System.out.println("Halleluya!"); 
        } 
    } 
}); 

this is my code, but it doesnt work. But if i do just like this:

this.addKeyListener(new KeyAdapter() { 
    public void keyPressed(KeyEvent ev) { 
        if(ev.getKeyCode() == KeyEvent.VK_SPACE){ 
            System.out.println("Halleluya!"); 

so i get "Halleuya" on the console. but i need just when CTRL + SPACE...

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Sagiv Asraf
  • 21
  • 1
  • 6
  • 1
    What type of GUI? JavaFX? Swing? If Swing then look into using [Key Bindings](https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html). Please show pertinent [mcve] code and add the important details (such as GUI library) to make your question more answerable. – Hovercraft Full Of Eels Jun 11 '17 at 14:44
  • Also your question is a multi-parter -- how to respond to key press, how to launch a new window, and you should try to solve both problems separately, and then if stuck, ask your questions separately. – Hovercraft Full Of Eels Jun 11 '17 at 14:50
  • thanks for your comment. 'code' this.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent ev) { if(ev.getKeyCode() == KeyEvent.VK_CONTROL + KeyEvent.VK_SPACE){ System.out.println("Halleluya!"); } } }); 'code' this is my code. it doesnt work. but if i do just like this: 'code' this.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent ev) { if(ev.getKeyCode() == KeyEvent.VK_SPACE){ System.out.println("Halleluya!"); 'code' so i get "Halleuya" on the console. but i need just when ctrl + space... – Sagiv Asraf Jun 11 '17 at 15:14
  • Please don't post code in comments but rather in the bopdy of your question as code-formatted text. So we see that it is a Swing question. Then your answer is to use Key Bindings. Please read the [tutorial on Key Bindings](https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html), and in the future if stuck, please strive to ask a much more specific and informative question. Please have a look at [Jon Skeet's StackOverflow Question Checklist](http://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Hovercraft Full Of Eels Jun 11 '17 at 15:18

0 Answers0