Can't get the keys to run anything...

Yeah, so I've literally spent the past two days trying to figure out how to get the keys to make stuff move in my game. I've already gotten the computer players to move around, implemented a collision detection system of sorts, and written the methods that will facilitate movement in the main person when called.
Here's my problem. I've been looking at several tutorials, and I see two primary ways of doing this. One, key binding, which I've been persuing more heavily, apparently requires use of a component. As of yesterday I didn't know what a component was, and since I've discovered that this method, in fact, requires an object that is a JComponent, which I don' t have in my program (I have a JFrame, but that's just a component). I was considering just slapping some random one in there, but I don't know how to set the key reading thing to do stuff even when the component is not selected. And I also think it would be sort of stupid to put superfluous stuff like that in my program.
The other method had tons of parameters and I really had no idea where they would all come from.
So, any suggestions?

in your main method or whatever put
addKeyListener(myKeyHandler())
// this class has 3 methods in java, keyPressed, keyTyped, keyReleased
myKeyHandler extends KeyAdapter
public void keyPressed(KeyEvent e)
int key = e.getKey//or something like that
if(key == VK.W)
up = true;
repaint();
else if(key == VK.S)
down = true;
repaint();
// if necessecary
try{ Thread.sleep(howeveramount)} catch(Exception f)
paint
if (up == true)
yPosition++
g.draw(thing);
else if(down == true)
yPosition--
g.draw(thing);
Edited by: nik7_7 on Apr 19, 2008 7:07 PM

Similar Messages

  • I can run a slide show using apple tv and itunes but can't get the slides to run in a specific order

    I can run a slideshow (of pictures) using Apple TV and ITunes but can't get the pictures to run in the order I set them up with in my hard drive directory

    Welcome to the Apple Community.
    Websites and third party Apps need enabling before they will allow AirPlay of Video content. Some Website/App developers have not enabled their products, some simply haven't got around to it yet, others have stated that they won't be enabling AirPlay (likely as a result of licensing issues).
    I have created a User Tip to list Apps that have been tested with Video Airplay, if you have any Apps that you have tested please leave details in the comments at the bottom of the User Tip or email me if you don't have commenting privileges.

  • I cloud worked fine for a while on the latest version of windows then threw up an error since then I can longer get the programme to run . I've reinstalled itunes but this doesnt help any ideas

    I cloud worked fine for a while on the latest version of windows then threw up an error since then I can longer get the programme to run . I've reinstalled itunes but this doesnt help any ideas

    It maybe worthwhile trying to uninstall and then reinstall the icloud control panel, if the issue is with your outlook.

  • How can I get the key list in ......

    The code such as UIManager.getColor("Table.selectionForeground") can get the default color of swing components,however,how I can get the key list on a swing component?
    Thanks a lot!

    Hello,
    you can get whole list withjava.util.Enumeration keys = UIManager.getDefaults().keys();
         java.util.Enumeration values = UIManager.getDefaults().elements();
         while (keys.hasMoreElements()){
              System.out.println("Key: "+keys.nextElement());
              System.out.println("Value: "+values.nextElement()+"\n");
         }search for special components.
    regards,
    Tim

  • Can't get the かな key to work on Japanese keyboard

    I've tried almost everything I could but I can't seem to get the かな or the 英数 keys to work. Can anyone help me get them programmed or tell me how to use them correctly?
    I'm using the Apple Japanese keyboard.
    Thanks

    Eajix wrote:
    Yes, every single other key works and the keys are in the right spots.
    Thanks for that info, which is important.
    Can you switch between Kotoeri and US input by using apple/command plus space?
    Do you know Japanese well enough to use the Japanese forums at
    https://discussionsjapan.apple.com

  • I can't get the applet to run please help me

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
         public class raceButton extends JApplet
         private int APPLLET_WIDTH=500,APPLLET_HEIGHT=35;
         private JButton Orc,Elf,Dwarf,Human;
         static String Race;
         public void init()
         setSize(APPLLET_WIDTH,APPLLET_HEIGHT);
         Orc= new JButton("Orc");
         Elf= new JButton("Elf");
         Dwarf= new JButton("Dwarf");
         Human= new JButton("Human");
         Orc.addActionListener(new ButtonListenerO());
         Elf.addActionListener(new ButtonListenerE());
         Dwarf.addActionListener(new ButtonListenerD());
         Human.addActionListener(new ButtonListenerH());
         Container cp = getContentPane();
         cp.setBackground(Color.red);
         cp.setLayout(new FlowLayout());
         cp.add(Orc);
         cp.add(Elf);
         cp.add(Dwarf);
         cp.add(Human);
         private class ButtonListenerO implements ActionListener
         public void actionPerformed(ActionEvent eventO)
              Race="orc";
              private class ButtonListenerE implements ActionListener
              public void actionPerformed(ActionEvent eventE)
              Race="elf";
              private class ButtonListenerD implements ActionListener
              public void actionPerformed(ActionEvent eventD)
              Race="dwarf";
              private class ButtonListenerH implements ActionListener
              public void actionPerformed(ActionEvent eventH)
              Race="human";
         static String getRace()
              return Race;
    this is what i do to activate it
         raceButton player= new raceButton();
         player.init();
         myRace=raceButton.getRace();(my race has already been initiated)
    it skips drawing the buttons and the action events

    this my full code
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class FirstDraft {
    public static void main(String[] args) {
    String orc="orc";
    String elf="elf";
    String dwarf="dwarf";
    String human="human";
    int again;
    Character player1= new Character();
    player1.begin();
    again=JOptionPane.showConfirmDialog(null,player1.getName()+ " are you sure you picked wisely?");
    while(again== JOptionPane.NO_OPTION)
         player1.setRace();
         again=JOptionPane.showConfirmDialog(null,player1.getName()+ " are you sure you picked wisely?");
    import chn.util.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Character
         private String myName;
         private String myRace;
         private String orc="orc";
         private String elf="elf";
         private String dwarf="dwarf";
         private String human="human";
         ConsoleIO keyboard=new ConsoleIO();
         void begin()// the first thing that happens.
         JOptionPane.showMessageDialog(null,"This is a public service announcement\n"
         +" My game makes fun of certain pictures and uses pictures with blood and death in them"
         +" if anything offends you I appologise, also all images are taken from google");
         setName();//goes into seting the name
         void setName()
         myName=JOptionPane.showInputDialog("What is your first name mortal?");//set's the name
         if (myName==null)
         setName();
         else
         intro();//goes into Intro     
         void intro()
         JOptionPane.showMessageDialog(null,"well \"" +getName()+ "\" if that is your real name"
    +"\nYou are going to face your friend to the death\n"+
         "the winner will live and I get the losers soul HAHAHAHAHA");
         setRace();// goes into setting the Race
         void setRace()
              JOptionPane.showMessageDialog(null,"Races available are :\n"+
              "the mighty orc\n"+
              "the mystical elf\n"+
              "the endurable dwarf\n"+
              "or the puny human you are.");
    raceButton player= new raceButton();
         player.init();
         myRace=raceButton.getRace();
         String getRace()//returns the Race
              return myRace;
         String getName()//returns the Name
              return myName;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
         public class raceButton extends JApplet
         private int APPLLET_WIDTH=500,APPLLET_HEIGHT=35;
         private JButton Orc,Elf,Dwarf,Human;
         static String Race;
         public void init()
         Orc= new JButton("Orc");
         Elf= new JButton("Elf");
         Dwarf= new JButton("Dwarf");
         Human= new JButton("Human");
         Orc.addActionListener(new ButtonListenerO());
         Elf.addActionListener(new ButtonListenerE());
         Dwarf.addActionListener(new ButtonListenerD());
         Human.addActionListener(new ButtonListenerH());
         Container cp = getContentPane();
         cp.setBackground(Color.red);
         cp.setLayout(new FlowLayout());
         cp.add(Orc);
         cp.add(Elf);
         cp.add(Dwarf);
         cp.add(Human);
         setSize(APPLLET_WIDTH,APPLLET_HEIGHT);
         while(Race==null)
         repaint();
         private class ButtonListenerO implements ActionListener
         public void actionPerformed(ActionEvent eventO)
              Race="orc";
         while(Race==null)
         repaint();
              private class ButtonListenerE implements ActionListener
              public void actionPerformed(ActionEvent eventE)
              Race="elf";
                   while(Race==null)
         repaint();
              private class ButtonListenerD implements ActionListener
              public void actionPerformed(ActionEvent eventD)
              Race="dwarf";
                   while(Race==null)
         repaint();
              private class ButtonListenerH implements ActionListener
              public void actionPerformed(ActionEvent eventH)
              Race="human";
                   while(Race==null)
         repaint();
         static String getRace()
              return Race;
    it never get's past player.init();

  • Can't get the software to run/install after downloading for HP Support site.

    I have window 8 OS and recently purchase a HP Ofiicejet  J4680 printer(All-In-One). The software CD for the print was only for window OS 2000, XP and Vista. I went to the HP support site and it had a software download for my OS. But after I downloaded and tried to install I got nothing. When I click run/open it shows "Extracting". Once it finishes extracting it just close and I can't find the .exe/setup.exe to run and install software. What am I doing wrong?

    Hi,
    Your printer is on the following list:
       http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&docname=c03168175
    Please try to download a tool (on the first screen) and run it on your Windows 8 computer.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Setting up email server address- can't get the / key to work!

    Hi!
    I have a Blackberry 8900 Curve that I have been given today as a work phone.
    I have followed the instructions to set up my work email on there. When promted to enter the work email server address, I can't seem to use the slash / symbol which is above the G key on the keyboard. I have Used the Alt key then pressed G, but all I get is a G!
    I have looked under the symbols menu and that has not worked. Also, I have noticed that it will only let me input certain symbols at this point, so perhaps this has been locked somehow?
    If it helps, at the top right of the screen is a small box containing '123' when I enter the section to enter the address. Perhaps I have some kind of lock on? But this goes away when i go to other fields in the setup wizard.
    Hope this makes sense! Any help would be fab, as this is a phone used by an old colleague and I do not have the manual!!  The IT support team are being as helpful as ever................!
    Thanks in advance!

    On the BlackBerry smartphone in the Enterprise Activation screen, the
    BlackBerry smartphone user types the email address and activation
    password.
    You shouldn't be entering a server address.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I need to upgrade from version 2 to use certain websites. I can download version 3.6 or but once opened I dont know what to do next, I just seem to geta big list and can't get the programme to run?? Can anyone help????

    My netbook is about 2 years old and came with firefox and linux. It has only been used for internet browsing and has been great......but now firefox version2 is out of date and sites such as facebook are not useable. It suggests i update to a newer version of firefox. I can find version 3.6 or 4 easily, download it but when I go to open it theres no run or prompts of how to install. I am not very computer literate to cant understand things that come of when I google for an answer!! Can anyone help me in easy to understand terms please??? thank you in advance

    I did that :
    Open Terminal
    1 - wget http://rpms.famillecollet.com/remi-release-8.rpm
    2 - sudo rpm -Uvh remi-release-8.rpm
    3 - sudo mousepad /etc/yum.repos.d/remi.repo
    Make sur that in remi section enabled value = 1 and in test section enabled value= 0
    4 - sudo rpm -e --nodeps firefox
    5 - sudo yum install firefox
    It was successful for me after many hours to look for the right answer

  • I can not get the trial to run for photoshop

    i cant get photoshop to work.  creative cloud allows me to get a photoshop app and it will only let me watch tutorials.what did i do wrong?

    I am having the same problem with the trial subscription of Photoshop.  In Creative Cloud, it shows Photoshop as downloaded.  Double clicking doesn't open anything.  The only option is "view tutorials."  The reason I wanted to try it is to create photo calendars with photos on the days of the month with a birthday, etc.  Does Photoshop do that?  Or does it just load photos as the picture above the calendar?

  • After trying to upgrade, I got the error 3014 and now I can't get the iPad to do anything. It continually shows the "plug in to iTunes" icon.  How do I get past this problem?

    Can't restore, can't power off, and pc can't detect iPad.  Error code 3014 when trying to upgrade.  Can't even restore to original settings. Opened Hosts files and I did not see 127....gs.apple.com, or other suggested files.  Pls help.

    Did you see the very end of this about not having enough space left on your computer specific to therror code 3014?
    Errors 3000-3999 (3004, 3013, 3014, 3018, 3164, 3194, and so on): Error codes in the 3000 range generally mean that iTunes cannot contact the update server (gs.apple.com) on ports 80 or 443.
    Update to the latest version of iTunes.
    Verify the computer's date and time are accurate.
    Check that your security or firewall software is not interfering with ports 80 or 443, or with the server gs.apple.com.
    Follow Troubleshooting security software. Often, uninstalling third-party security software will resolve these errors.
    An entry in your hosts file may be redirecting requests to gs.apple.com (see "Unable to contact the iOS software update server gs.apple.com" above).
    Internet proxy settings can cause this issue. If you are using a proxy, try without using one.
    Test restoring while connected to a known-good network.
    Error 3002: If you experience this error while updating an iPod touch (2nd generation) or iPhone 3G, please use the standard update or restore process in iTunes (click Update or Restore).
    Error 3014 may indicate that you need to free up more disk space on the computer before trying to restore again.

  • How can I get the printer to run quietly. HP Officepro 8600 Plus. Windows 7 Starter edition,

    The printer is very noise.

    Refer to http://h30434.www3.hp.com/t5/Other-Printing-Questions/My-printer-is-noise-OfficePro-8600-plus/td-p/1...
    I am an HP employee.
    Say Thanks by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as "Accepted Solution"

  • How can I get the text value of an XML element  in MXML ?

    Hi,
    I have the following XML loaded into a variable of type XML :
    <properties>
         <comment>RIMpro Data Collector Configuration</comment>
         <entry key="server.pear.username"/>
         <entry key="server.apple.retry.times">5</entry>
         <entry key="rdc.proxy.host">http://192.168.1.2:8080</entry>
    /properties>
    I can easily get the key attribute displayed in a DataGridColumn by setting the dataProvider to my variable and the dataField to "@key".  But I do not know how to get the text value in a second column...  Is there a way or do I need to change my XML to something like this :
    <properties>
         <comment>RIMpro Data Collector Configuration</comment>
         <entry key="server.pear.username"/>
         <entry key="server.apple.retry.times" value="5"></entry>
         <entry key="rdc.proxy.host" value="http://192.168.1.2:8080"></entry>
    /properties>
    Many thanks in advance.
    Marc

    yes, you'd better modify your XML structure to fit the DataGrid internals.
    Since dataField pattern require each grid row item to have a named property to be displayed, otherwise you'll be forced to overcome this pattern using custom labelFunction for the particular column which will implement your custom actions on how to extract appropriate data for that column out of grid row item. It will be much more complicated than just rearranging your xml structure.

  • I can not get the flash player plug in to work with Internet Explorer

    I can not get the flash player plug in to work with Internet Explorer

    Zoltan71 wrote:
    I just bought this computer. My Internet Explorer is version 11.0.1
    I have the box checked to Install new version automatically, but it has not done any upgrading.
    I can't get the computer to update anything as far as I can see.
    The flash plug in does work with the Crome browser but it will not work with Internet explorer.
    I looked in the manage add-ons and it says enabled.
    I also went into the safety tab and deselected
    Active X filtering.
    Restarted and still does not work.
    I need help.....
    Chrome uses a different and separate plug-in.
    There are things about IE you need to know, especially 11. Specifically:
    "User-Agent Strings"
    That doesn't mean a lot, I'm sure, but it's the root of your problems, and Flash Player has nothing to do with it.
    Microsoft "rewrote" the User-Agent Strings for the abomination they call their latest and greatest browser. User-Agent Strings are what websites use to identify the browser you're using and provide the proper content for it's browser engine, like ActiveX stuff, and Flash or HTML5 video. Thanks to the geniuses in Redmond, WA, the User-Agent Strings for IE11 (which has a Trident engine), ID it as either "Gecko" (Firefox) or "Webkit" (Chrome). Problem is: when the site the directs to the content for one of these two engines, the Trident engine in IE can't intepret it and the site then sees IE as an "unidentified" browser.
    The problem with an unidentified browser is that the plug-ins in that browser aren't recognized either, so even though you're up to date, it says you need the latest Flash Player when you use IE11. YouTube... has converted to HTML5 video so if it doesn't detect Flash Player, it can display HTML5 (MP4) video which requires no plug-in to play. Facebook can't do that, because HTML5 doesn't apply to games... only video.
    Microsoft has no plans to "fix" the mess they've created because they think it's a great idea to block you out of the websites you visit.
    They recommend using "Compatibility View" and pretending that you're using an older verison of IE... Problem with that is that it's seen limited success, and you have to enable it for EVERY page that has problems... individually.
    I'm not big on "pretending" so I recommend actually using another browser.
    Firefox (from Mozilla)
    Opera (from Opera)
    Safari (from Apple)
    Chrome (from Google)
    ANY of those will work where IE11 won't, with the Flash Player Plug-in (For all other browsers), and Chrome doesn't even need that because it has its own Flash Player plugin built in.

  • Can not get JSP examples to run

    I am able to use the example servlets, but I can not get the JSP examples to run. I get the error listed at the end of this message.
    I am using jdk1.3.x and TOMCAT Version 3.2.3
    Here is my classpath
    .;C:\jdk1.3\jre\lib\rt.jar;c:\jdk1.3\lib\tools.jar;C:\jakarta-tomcat\webapps\privilegesparadox;C:\jdk1.3jre\lib\ext\XML4J.JAR;C:\jdk1.3\jre\lib\ext\mm.mysql-2.0.4-bin.jar;C:\jdk1.3jre\lib\ext\mssqlserver.jar;C:\jdk1.3\jre\lib\ext\mail.jar;C:\jdk1.3jre\lib\ext\activation.jar;C:\Netscape\Servers\java\ldapjdk.jar
    I am running this on win2000. I have done several years of servlet work and now am needing to do JSP stuff. I can not get the examples to run... so any of my test stuff does not work either.
    Error: 500
    Location: /examples/jsp/dates/date.jsp
    Internal Servlet Error:
    javax.servlet.ServletException: sun/tools/javac/Main
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:508)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Root cause:
    java.lang.NoClassDefFoundError: sun/tools/javac/Main
         at org.apache.jasper.compiler.SunJavaCompiler.compile(SunJavaCompiler.java:136)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)

    I don't get it... I have been using jdk 1.3.x for sometime... a year now. All seems fine with servlets and java applications I have created. What could be not there if all of this works?
    If reinstall the jdk over top of where is is now, would that be of any help? I will copy my /ext jar files to a temp area first so I can keep my jar files.
    Dean-O

Maybe you are looking for