LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2009, 10:24 PM   #1
mjw2010
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
Java KeyListener not working in Linux


Hello guys,
I made a Pong java applet for my programming class.
It works in the Windows OS, but I'm having an issue running it under Ubuntu.
When I run my applet, My KeyListener does not respond with the code I have programmed.
for example, when I press the Up/Down arrow keys, the paddle does not move up or down.
However, the applet draws just fine, and my timer works.
Do I need to use a different KeyEvent than I am using in the code here:

Code:
 public void keyPressed(KeyEvent event) 
    { 
        int keyCode = event.getKeyCode();
        if(keyCode == KeyEvent.VK_UP)
        { 
            pd1.y -= 25;
            repaint(); 
        }
Again, the program works perfectly in Windows.
I am guessing there is something wrong with the line:
"keyCode == KeyEvent.VK_UP"
 
Old 12-07-2009, 03:09 AM   #2
bmarx
Member
 
Registered: Dec 2004
Distribution: Slackware, Arch, FreeBSD
Posts: 202

Rep: Reputation: 34
Printing out the values you are getting for VK_UP and keyCode would be a good place to start. Then you could use xev and xmodmap if necessary.
 
Old 12-09-2009, 01:53 PM   #3
mjw2010
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
I'm having issues with the Java console.
It does not appear when I view my applet in Applet Viewer.
But when I load the applet in firefox, sometimes the console appears, sometimes it does not, and sometimes I just get a brown box where my applet should be.
 
Old 05-29-2011, 10:15 PM   #4
sombriks
LQ Newbie
 
Registered: Jan 2006
Posts: 5

Rep: Reputation: 0
http://www.javakb.com/Uwe/Forum.aspx...Pane-in-applet

maybe it helps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Web start java not working (java works fine) powadha Debian 5 06-05-2004 01:57 PM
while working java i wanted to use it linux navalarora Programming 3 11-24-2003 08:54 AM
while working java i want use linux navalarora Linux - Software 2 11-24-2003 07:30 AM


All times are GMT -5. The time now is 08:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration