My Teacher Doesn't Teach us, So I Resort To Forums

This is a nub question on how to do something (probably). I've been working on this for the past few days and I can't figure this out. The window doesn't refresh unless done so manually by minimizing and maximizing. I want it to refresh constantly, or at least when something changes.
Here's my code. Thanks in advance to anyone who helps me.
main class:
import javax.swing.JFrame;
public class graphicstester
    public static void main(String[] args)
        JFrame frame = new JFrame ("Hey");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        graphicstest graphics = new graphicstest();
        frame.setContentPane(graphics);
        frame.setSize(256,256);
        frame.setVisible(true);
}method class
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
import javax.swing.Timer;
import javax.swing.JFrame;
public class graphicstest extends javax.swing.JPanel
Graphics g;
int[][] d00d;
int x,y;
boolean hey;
public graphicstest()
init();
public void init()
                 int[][] d00d = { {0,0,1,1,1,1,0,0},
                 {0,0,1,1,1,1,0,0},
                 {0,0,0,1,1,0,0,0},
                 {1,1,1,1,1,1,1,1},
                 {0,0,0,1,1,0,0,0},
                 {0,0,1,1,1,1,0,0},
                 {0,1,1,0,0,1,1,0},
                 {1,1,0,0,0,0,1,1}};
int[][] block = { {1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1}};
int[][] map = { {1,1,1,1,1,1,1,1},
{1,2,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1}};
        setFocusable(true);
        addKeyListener( new KeyPress() );
        setBackground( Color.green );
        x = 3;
        y = 3;
protected void paintComponent(Graphics g)
        super.paintComponent(g);
        g.drawRect(x,y,4,4);
public void update(Graphics g)
super.update(g);
public class KeyPress      implements KeyListener
        public void keyPressed(KeyEvent event )
                if (event.getKeyCode() == KeyEvent.VK_W )
                 if(fits(x,y-1)){
                     y--;paintComponent(g);}
                if (event.getKeyCode() == KeyEvent.VK_A )
                 if(fits(x-1,y)){
                     x--;paintComponent(g);}
                if (event.getKeyCode() == KeyEvent.VK_S )
                 if(fits(x,y+1)){
                     y++;paintComponent(g);}
                if (event.getKeyCode() == KeyEvent.VK_D )
                 if(fits(x+1,y)){
                     x++;paintComponent(g);}
        public void keyTyped( KeyEvent event )
        public void keyReleased( KeyEvent event )
public boolean fits(int x,int y){
boolean fits = true;
if((x>256)||(x<0)||(y>256)||(y<0)){fits=false;}
return fits;
public void sprite()
}

import javax.swing.JFrame;
public class GraphicsTester
  public static void main(String[] args)
    JFrame frame = new JFrame("Hey");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new GraphicsTest());
    frame.setSize(256, 256);
    frame.setVisible(true);
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public class GraphicsTest extends JPanel
  private static final long serialVersionUID = 79300887978351264L;
  int x, y;
  public GraphicsTest()
    setFocusable(true);
    addKeyListener(new KeyPress(this));
    setBackground(Color.GREEN);
    this.x = 3;
    this.y = 3;
  protected void paintComponent(Graphics g)
    super.paintComponent(g);
    g.drawRect(x, y, 4, 4);
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class KeyPress implements KeyListener
  private GraphicsTest parent;
  public KeyPress(GraphicsTest parent)
    this.parent = parent;
  public void keyPressed(KeyEvent event)
    if (event.getKeyCode() == KeyEvent.VK_W)
      if (fits(this.parent.x, this.parent.y - 1))
        this.parent.y--;
    if (event.getKeyCode() == KeyEvent.VK_A)
      if (fits(this.parent.x - 1, this.parent.y))
        this.parent.x--;
    if (event.getKeyCode() == KeyEvent.VK_S)
      if (fits(this.parent.x, this.parent.y + 1))
        this.parent.y++;
    if (event.getKeyCode() == KeyEvent.VK_D)
      if (fits(this.parent.x + 1, this.parent.y))
        this.parent.x++;
    this.parent.repaint();
  public void keyTyped(KeyEvent event)
  { /* nothing */ }
  public void keyReleased(KeyEvent event)
  { /* nothing */ }
  private boolean fits(int x, int y)
    return !(x > 256) || (x < 0) || (y > 256) || (y < 0);
}

Similar Messages

  • Flash doesn't work after I updated it

    I am using Firefox 34.0.5 and updated my flash player but after the update it stopped working. The videos doesn't show up. I tried disabling all add-ons and found out that Shockwave Flash 16.0 is causing the problem. What should I do to make it work again?
    I don't know why but some videos work just fine and other videos doesn't show anything even a white or black screen, even though they're from the same site. When a video doesn't show up, the cursor changes from the normal cursor to "working in background" cursor rapidly.

    ''Talha [[#answer-672921|said]]''
    <blockquote>
    Hey,
    Did you try these typical Flash fixes?
    (1) Disable hardware graphics acceleration in Firefox and in Flash
    (A) In Firefox, un-check the box here and restart:
    orange Firefox button or classic Tools menu > Options > Advanced > General > "Use hardware acceleration when available"
    (B) In Flash, see this support article from Adobe: http://helpx.adobe.com/flash-player/kb/video-playback-issues.html#main_Solve_video_playback_issues
    (2) Disable protected mode (Win Vista & Win 7 & maybe Win 8)
    See this support article from Adobe under the heading "Last Resort": Adobe Forums: https://forums.adobe.com/message/4468493#TemporaryWorkaround
    Hope it helps.
    </blockquote>
    I did both of these but it still didn't work. I tried using another browser and found out that the problem only occurs in firefox.

  • Cancel Subscription doesn't work !!!

    1) On a expired Skype Number subscription, Skype keeps trying to charge the Credit Card 2) Even worse, it doesn't let the end user remove the Credit Card. It claims that it is required to cancel subscription first, but when the option is selected, nothing happens! 3) Hence, the subscription cannot be cancelled and the credit card cannot be removed. 4) The Support Contact Page doesn't offer an option to report issues like this. What is going on here?????  

    1.  Skype numbers are subscriptions so they will renew.  The renewal is billed 3 days before the subscription ends and continues to attempt to bill with the information on file for those 3 days.  If the payment doesn't go through it will resort to cancelling the subscription due to non-payment. 2.  You need to add a new credit card or cancel the subscription.  You can add a new credit card at any time.  You can cancel the subscription at any time.  If for some reason certain buttons don't work right, try another web browser.  The issue may exist with your web browser or a plug-in you have installed. 3.  You can't delete any credit card in use by a subscription unless you cancel that subscription.  If  you have another credit card on file you can switch payment of that subscription to that credit card.  You will then be able to delete the card on file as well.  This is rather common and makes sense to me.  Paypal subscriptions work the same exact way. 4.  You can contact Skype Customer Service but I believe that they may just walk you through the same exact process.   Skype Customer service can be contacted by filling out a Support request options on the Support Request page. https://support.skype.com/en/faq/FA1170    

  • Save for previous version doesn't warn about incompatibilities

    I just back-saved some code from LV2012 to LV2009. The code included some conditional indexing. I expected that either:
    The code would be converted to a LV2009 functional equivalent without conditional indexing
    I would get a warning about the incompatibility
    I was disappointed to find that I got neither....
    I thought we previously got warnings about incompatibility... Or is my brain superimposing some wishful thinking onto my memories again?
    Chris Virgona
    Solved!
    Go to Solution.

    Just getting back to this thread after a busy week...
    The project that I backsaved included 2 VIs with conditional indexing. Neither had particularly complicated logic and the data types were a scalar and a small flat cluster of standard types. The one interesting thing about it was that both myself and a colleague both noticed the problematic backsave on different PCs and with different revisions of the code.
    Anyway, I since tried to reproduce the issue but failed... (Doesn't that always happen straight after a forum post?!) Now when I do a backsave (on similar code, lost track of the original code where I noticed this) I get the build array + case structure + shift register...
    BUT there is one problem: The new shift register always seems to be uninitialised. That seems buggy to me... (It definitely produces defective code in my case.) Is it that way by design for some reason??
    Chris Virgona

  • Home tab doesn't work

    When I open the Creative Cloud window and choose the Home (Start) tab,
    I only get an spinning wheele...:(
    How can I solve this problem?

    When when I tried this. First 1, then 2 and at least step 3.
    I removed the Creative Cloud and couldn't start it again.
    The I get an error when I want to install it from my browser:
    aam://SAPCode=KCCC?productVersion=2.0?passPhrase=bbwLnoSgzvZbHDotOY9YAYd5aI4MBOCFSWeKF9ujE LVU8U13Z5unat3IVyqWyvn69srsWamjxSEAYDYF3ESDCyuMlqrKXVu3QWwhDZllvO2bGH5lhUjvgqzDsL/gXPFV0HU bJIWolcMlHqnzjRIQ3rraFtfODkpLDaTvfd2TiHI=
    2013/7/4 Sumit Singh <[email protected]>
       Re: Home tab doesn't work  created by Sumit Singh<http://forums.adobe.com/people/Sumit+Singh>in
    Adobe Creative Cloud - View the full discussion<http://forums.adobe.com/message/5476428#5476428

  • Touch doesn't work after clean install of Windows 7 Professional

    I have an IQ526t.  I did a clean  install (remove drive/repartition/format drive) of Windows 7 Professional, and now the touchscreen feature doesn't work.  I've been on forums here and at Mirosoft, downloaded various drivers, rebooted multiple times, etc....no luck.  I get the sound, but no response.   Thoughts???

    Hello bmarkj,
    Welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the HP Forums I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More.
    I understand that you have removed the recovery drive and installed Windows 7 by not using the OEM version that came with your computer. You have a couple options here, first you can download and install the HP Support Assistant and let it download and install the software and drivers that came with your computer. You can alter the settings so that the updates are manually done giving you control over what gets updated and what does not. Or you can download and install the drivers and what software you want from HP TouchSmart IQ526t CTO Desktop PC Drivers page. The choice is yours.
    ***NOTE: Be warned that there is software that come with some of the computers that is ONLY available from the recovery drive so you may not see everything you are used to seeing. The only way of recoverying this software is through the HP Recovery Discs.
    I hope I have addressed your question to your satisfaction. Thank you for posting on the HP Forums. Have a great day!
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • I just bought an iMac and I´m a new user of Mac.  I captured my data and my country is Mexico. What can i do if the final data check show España? Is it important or it doesn´t matter?

    I just bought an iMac and I´m a new User of Mac. I captured my data and my country is Mexico. What can i do if the final data check of Mac shows Spain? Is it important or it doesn´t matter?

    Hola & welcome to the Forums!
    Have you noticed any problems, like Time zone or Time display?

  • [solved] dnsmasq doesn't start

    After last yesterdays upgrade my dnsmasq could not start. Init script shows it started properly, but there wasn't any dnsmasq process. There was nothing in log also.
    I tryed to resync package, and I get this: (I translated polish errors descriptions)
    error: I could not made transaction (files conflicts)
    dnsmasq: /etc/rc.d/dnsmasq exists in file system
    dnsmasq: /usr/sbin/dnsmasq exists in file system
    dnsmasq: /usr/share/man/man8/dnsmasq.8 exists in file system
    pacman -Sf did the trick and now it works fine, but I wrote this for a record. Maybe samoeone have similar problem, or you will want to take a look in Pacman, because it doesn't look like good behavior.

    See this forum thread about Firefox hanging during startup; the bug in Firefox Bugzilla is marked fixed, but maybe the discussion will give you any interesting idea.
    When I had found, that my apparently broken FF3 works when run as root, and there is no permission related errors in strace output, I started with comparison of environment variables, and this eventually led me to the workaround, maybe try it.

  • Sge2000 just doesn't route in a sane manner

    I have 3 vlans on a standalone SGE2000 in Layer 3 mode. VLAN 1 for servers, VLAN2 for workstation and VLAN100 for management. All the servers in VLAN1 can see and talk to one another. Router for internet is also connected to VLAN1. All servers have internet access like expected.
    I only have a single machine in the Workstation VLAN for testing right now. It can access some of the servers but not all. It can also access the internet properly, but certain servers it just won't talk to.
    Now this is the weird part. If I move the workstation over to the management VLAN and change it's IP address accordingly, it will begin to talk to the other servers it would not talk to before. But then it won't talk to the internet router which is in the same VLAN as the servers.
    The servers it can't access though are using other advanced features or unique scenarios. One is a file server with 4 ports aggregated with LACP. The LAG group is in the proper VLAN and the other servers can access this so I'm pretty sure that is all built properly.
    The other servers it can't access are VM's on ESX 3.5. There is no VLAN tagging going on in the ESX server. All VM's attach to the same interface on the physical server and are in the same subnet as the management IP of the ESX server. My test workstation in the other VLAN can load the web management for the ESX server, but can't contact any of the VM's. Again, these VM's are in the same subnet and bound to the same interface as the Web management that can be accessed.
    Without changing any other port configurations, if I move the workstation to the same VLAN as the servers, it can access everything without issue.
    It would seem that's there's some sort of bugginess in the way the switch selectively routes for certain IP's and certain VLANS.
    I have no ACLS in place, all ports in all VLANS are set to access mode. None of the machines have software firewalls. The switch itself can ping all machines in question in all VLANS. All machines use their respective switch vlan interface IP as their default gateway. Switch has default route pointed at router in VLAN1.
    I'm pretty convinced at this point that the firmware in the switch is buggy.
    If no one has any ideas, my next step is to start sniffing traffic destined for the port of the ESX server and see if packets from the workstation arrive there at all. That's the closest way I can figure to determine if the switch is even trying to forward packets from the other VLAN to the VM's.
    If that doesn't reveal anything, my only resort appears to be to sell my wife's car and buy a Cisco.

    Kinda weird problem you got there. Have you tried re-flashing the firmware?

  • On a 1512 when printing on e-bay current bid doesn't print

    when I print an e-bay page current bid doesn't print

    Hi @mjsharley,
    Welcome to the HP Forums!
    I see that when printing on e-bay current bid does not print with your HP Deskjet 1512 printer. I am happy to help you with this printing issue!
    For further assistance, I will need to know the following information:
    If you are using a Windows or Mac Operating System, and the version number. To find the exact version, visit this link. Whatsmyos.
    If the printer is able to make a test page. Video: Printing a Test Page - HP Deskjet 1510 All-in-One Printer.
    If the power cable is plugged into a surge protector, or directly to the wall outlet. Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector. This applies to Inkjet printers as well.
    The name of the program you are trying to print from.
    If you can print from other programs.
    If you are using Windows please try our HP Print and Scan Doctor, and let me know what happens!
    Please see this post, Want Good Answers? Ask Good Questions, by @Bob_Headrick, so you can get the most out of these forums.  
    Thank you for posting!
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • Airplay doesn't work on my iphone 4S

    My airplay was working yesterday with my iphone. But this morning, impossible to connect my iphone to my ATV 3. Icon is still on my phone but when i active it nothing happen on my tv.
    But it works fine with my Macbook and my iPad, so i don't understand what's happening.
    I've already reset my ATV and my iphone and it's still doesn't work.

    A quick search of the forums, I found what might be the solution as I was about to post the same question you did.
    If you have the iPhone 4S, double tap the home button then slide (Left to right) twice. You should see the Air Play icon on your iPhone screen. Tap that and it will give you an option to select your Apple TV then it sets up mirroring between iPhone and Apple TV. I am about to try and play one of my games that is on my phone and use my Apple TV to play it on my big screen TV.

  • Lightroom 3.6 upgrade doesn't work

    After having installed the 3.6 upgrade I have problems every time I mark an image and select the Update tab. The image is not loaded and I have to force the program to halt.
    When I try to use the Adobe site to contact support my serial number for Lightroom 3 is not valid.
    I have seen others with similar problens on the forum and I hope Adobe can fix the problem soon as the program is currently not usable.
    I would appreciate if there is a way to go back to version 3.5?
    Regards,
    Rolf

    When I mark/select a imge in my library and the click the Develop module,
    the loading of the image never completes.
    Sorry, I used the term Update instead of Develop because I made a bad
    translation of my Swedish tab "Framkalla".
    I'm using Mac OS X 10.5.8.
    Rolf
    2011/12/15 Julie Kmoch <[email protected]>
       Re: Lightroom 3.6 upgrade doesn't work
    created by Julie Kmoch <http://forums.adobe.com/people/Julie+Kmoch> in *Downloading,
    Installing, Setting Up* - View the full discussion<http://forums.adobe.com/message/4087187#4087187>

  • INDESIGN CS6 DOESN T RUNNING

    I am Indesign CS6.
    When I run Indesign message looks :
    HWN DBASED PANEL VIEW UID : 169353.
    And my files d'ont run.
    I am nothing.
    I am PC window 7
    How resolve my probleme ?
    Chrystèle [email protected]

    YES
    Thank you
    Bien cordialement.
    C.LAKHDAR-BARKA
    SUNSTEEL SAS
    Tél direct : 04 90 88 77 32
    Courriel :  <mailto:[email protected]> [email protected]
    Site Web : :  <http://sunsteel.eu/> http://sunsteel.eu
    De : Peter Spier 
    Envoyé : mercredi 10 décembre 2014 11:07
    À : CHRYSTELE LAKHDAR-BARKA
    Objet :  INDESIGN CS6 DOESN T RUNNING
    INDESIGN CS6 DOESN T RUNNING
    created by Peter Spier <https://forums.adobe.com/people/P+Spier>  in InDesign - View the full discussion <https://forums.adobe.com/message/7001632#7001632>

  • Xorg.conf doesn't keep configuration of two screens sharing one corner

    I explained my situation in this thread.
    Trilby recommended do set up the screens like this (thanks!):
    +---------------------------+
    | |
    | |
    | |
    | |
    +---------------------------+
    +-----------------+
    | |
    | |
    | |
    +------------------+
    So using nvidia-settings (I know it's bad), I made this:
    Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "Stereo" "0"
    Option "nvidiaXineramaInfoOrder" "DFP-1"
    Option "metamodes" "DFP-0: 1366x768_60 +1920+1080, DFP-1: 1920x1080_60 +0+0"
    SubSection "Display"
    Depth 24
    EndSubSection
    EndSection
    After setting up everything in nvidia-settings and applying it, the monitors are in right position. The problem is that after a reboot, the smaller screen moves up, so it's not +1920+1080, but +1920+0.
    Can it be connected with this issue?

    ravicious wrote:but I really want to find a solution to this problem :C
    Doesn't mean that you muddy up the forum. Do some researching on the issue while waiting for someone to answer. Post what else you have tried which hasn't worked so others don't waste time giving you the same solution.

  • Download Error for apps from Creative Cloud desktop

    I have just signed up for the CS6 cloud package. As a teacher, I've paid for the Student or Teacher arrangement. However, I have not been able to download and install any of the applications. My first attempt was to download Acrobat from the website downloader; the system went throught the motions of installing the Application Manager app, but failed even though the icon was installed on my desktop. So I tried by installing the Creative Cloud desktop app. The installation seemed successful, but a cannot even get to see the apps and get a Download Error message!

    Hi, Deian47
    If the above link doesn't work then follow the thread http://forums.adobe.com/message/5469534, it has all the possibilities and their solutions.
    Thanks!
    Ankit

Maybe you are looking for

  • DaRT with Windows 8.1 not working on some machines

    Problem: x64 bit DaRT8/801/8.1 not recognizing the OS and utlities are greyed out/unavailable on some machines. System: Windows 8.1 x64 Steps taken: Tried different DaRT toolset versions, set BIOS SATA operation to different modes, tried both UEFI an

  • I cloud Music storage

    I downloaded an album on my phone and took up storage space. Can I transfer it to the cloud to free up space on the phone? i phone 4.

  • BUG IN FINGERPRINT SOFTWARE!

    I believe there is a bug in the IOS 7.0.4 fingerprint reading software. Supposedly, that software learns and becomes more accurate with usage. However, I have found that it becomes LESS accurate with usage! I have had to re-enter my fingerprints thre

  • Can't Print after 10.5.8 update - HP 6310 + G5

    I updated the G5 to 10.5.8 last night. Can't print today. Everything is plugged in and connected. The printer was "published." I reset the printing services. The printer no longer shows up as an option to add in the Preferences pane. HP has no update

  • Why does iMovie lock up every time I use it?

    I am trying to create a new movie and iMovie keeps locking up.  This has never happened before.  I have no other programs running.  Please help.