Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 KeyListen (outputs keycodes&keytext)
Index -> Programming, Java -> Java Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
the_short1




PostPosted: Thu Jun 01, 2006 10:42 am   Post subject: KeyListen (outputs keycodes&keytext)

A simple program i made to give the keycode and keytext values (output sent to terminal window), as you type in the gui window.

I used it to give me the values for all of my Menu shortcut keys (eg. pressing ctrl+s to save, keycode=83, keyText=S), and special ones like keyCode=8 and keyText="Backspace" to backup a move in my game.

If you have any questions/comments just pm/reply.

-kevin



KeyListen.java
 Description:

Download
 Filename:  KeyListen.java
 Filesize:  1.79 KB
 Downloaded:  291 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
cool dude




PostPosted: Thu Jun 01, 2006 4:38 pm   Post subject: (No subject)

this will probably sound stupid but i can't exit the program unless i go to task manager and end the task. how would i exit the program?
HellblazerX




PostPosted: Thu Jun 01, 2006 4:45 pm   Post subject: (No subject)

Hmmmmm, looks like you forgot this:
code:

setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

Otherwise people would have to close whatever they're using to run the program, rather than the JFrame itself.
cool dude




PostPosted: Thu Jun 01, 2006 4:53 pm   Post subject: (No subject)

for some reason its not working for me. it says cannot resolve symbol varaible jframe
HellblazerX




PostPosted: Thu Jun 01, 2006 4:57 pm   Post subject: (No subject)

Ooooo, I see. He's using the old awt containers, not the new Swing ones. And it doesn't seem like the old containers have such a command. Looks like you'll have to add a WindowListener to close the program, but I can't be sure, seeing as I have never used them before.
[Gandalf]




PostPosted: Thu Jun 01, 2006 5:09 pm   Post subject: (No subject)

Something like so should do:
Java:
addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
});

Though really, there is no reason for you not to be using JFrame instead... It only takes a few keystrokes to change.
the_short1




PostPosted: Thu Jun 01, 2006 6:30 pm   Post subject: (No subject)

ty gandalf for informing them how to close the awt window, but seing as i wanted to keep it simple i didnt include that.

To close the program, close the DOS window, and it will automatically close the GUI window Smile... (and this works for most if not all programs)
cool dude




PostPosted: Thu Jun 01, 2006 7:42 pm   Post subject: (No subject)

but i'm not in DOS when i run it. i run it through Blue J and it won't close! thats why i posted for help on this question because at times i make an endless loop and i can't close the window.
Sponsor
Sponsor
Sponsor
sponsor
the_short1




PostPosted: Thu Jun 01, 2006 9:53 pm   Post subject: (No subject)

ohh.. i use JCreator.. . what is blueJ? ive never heard of it.
hmm.. . well for my current game im working on i send a lot of debugging to the terminal (dos) window, why dont you see it ? what happens to all your System.out.println's?
cool dude




PostPosted: Fri Jun 02, 2006 7:26 pm   Post subject: (No subject)

since i'm kinda new i don't know wat JCreator is and where to get it, but Blue J is wat most schools use (i think). it's really easy because all i have to do is write the code and then press the button compile to compile it and then i just run it by pressing a button. simple as that. instead of going to java typing the path and all that stuff. the system.out.println's just display in the terminal window and i never said i don't see them. your program works perfectly fine and i see it its just that i can't exit it but gandalf fixed that issue
the_short1




PostPosted: Sat Jun 03, 2006 10:58 am   Post subject: (No subject)

ahh just a misunderstanding then Smile .. our class commonly calls the terminal window the dos window.... JCreator is used by the whole algoma district school board, and it is probally really similar to BlueJ, http://www.jcreator.com/..

Im still curious: does closing the 'terminal' window in bluej close this program as well?

-kevin
cool dude




PostPosted: Sat Jun 03, 2006 5:01 pm   Post subject: (No subject)

u can't close the program in Blue J by clicking on the "x" because it doesn't work! the only way is to end the program by having a command in your code i.e. type 0 to exit and in your code make it so that it exits. then u can click on the close button and it will close the running program.
cool dude




PostPosted: Sat Jun 03, 2006 8:45 pm   Post subject: (No subject)

wow JCreator is so much better! thanks for the link Smile
just a quick question wat is the difference when u go to file and it says new file or new project?
the_short1




PostPosted: Sun Jun 04, 2006 12:15 pm   Post subject: (No subject)

well .. if your just making small programs.. go new file.. best feature of jcreator is the auto indent and auto brackets (which can be turned off in options), and nice syntax highlighting. ohh and the debugger is pretty good.

projects is for manipulating multiple source code files within one program.. eg. my pegged game, i have a main.java menu.java and verify.java, when i add all 3 to a project i can access methods from one another as if it was one big file.

no problem Smile
cool dude




PostPosted: Sun Jun 04, 2006 12:21 pm   Post subject: (No subject)

also when i open a new file it doesn't automatically put the class name i.e.
code:

public class example


is there any way to make that automatic or do u have to type it every time because in BlueJ it was automatic. also when u say you could access the methods from one another as it was one big file do u have to write something in your code or it automatically accesses it?
Display posts from previous:   
   Index -> Programming, Java -> Java Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: