JComponent.setbackground(Color.BLACK) is NOT working

I am creating Space Invaders game and have GamePanel as my JComponent, named panel. The background is not changing for sum reason though???
import java.awt.*;
import javax.swing.*;
public class SpaceInvaders{
     //variables
     public static final int WIDTH = 800;
     public static final int HEIGHT = 800;
     GamePanel panel;
     public SpaceInvaders()
          //create frame
          JFrame demoFrame = new JFrame("Space Invaders");
          demoFrame.setBounds(0,0,WIDTH,HEIGHT);
          demoFrame.setVisible(true);
          demoFrame.setResizable(false);
          demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          demoFrame.setBackground(Color.BLACK);
          //create panel
          GamePanel panel = new GamePanel(this);
          panel.setBackground(Color.BLACK);
          demoFrame.add(panel);
          //add buttons
          JButton startButton = new JButton("Start");
          startButton.setEnabled(true);
          JButton stopButton = new JButton("Stop");
          stopButton.setEnabled(true);
..... import java.awt.*;
import javax.swing.*;
import java.awt.Image;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.image.BufferStrategy;
import javax.swing.*;
import java.awt.event.*;
public class GamePanel extends JComponent implements KeyListener, ActionListener
     SpaceInvaders game;
     static Player player1;
     Bullets bullet;
     private BufferStrategy strategy;
     static int alienNum = 36;
     static int alienRow = 6;
     static int alienCol = 6;
     static Aliens[][] aliens;
     static Bullets[] bullets;
     private Timer timer;
     int bulletNum=0;
     public GamePanel(SpaceInvaders game)
          this.game = game;
          player1 = new Player(this);
          player1.start();
          aliens = new Aliens[alienRow][alienCol];
          for(int i=0; i<alienRow; i++)
               for(int j=0; j<alienCol; j++){
                    aliens[i][j] = new Aliens(this);
                    aliens[i][j].setX(i*50);
                    aliens[i][j].setY(j*50);
          bullets = new Bullets[5];
               bullets[0]=new Bullets(this);
          timer=new Timer(500, this);
          //timer.setDelay(500);
          timer.start();
          this.setFocusable(true);
        this.addKeyListener(this);
     public void paintComponent(Graphics g)
          super.paintComponent(g);
          Image pic1 = player1.getImage();
...........

I changed the GamePanel class to extend JPanel instead of extend JComponent and it works now. Didnt realise JComponent had no paint functions.. Thanks for your help.
import java.awt.image.BufferStrategy;
import javax.swing.*;
import java.awt.event.*;
public class GamePanel extends JPanel implements KeyListener, ActionListener
     SpaceInvaders game;
     static Player player1;
     Bullets bullet;
     private BufferStrategy strategy;

Similar Messages

  • (three-way color corrector) secondary color correction masks not working?

    Hi I'm using PP 2014 on Yosemite. Anyone notice (three-way color corrector) secondary color correction masks not working?

    strange. same stats here but im getting intermittent.... sometimes i can use the mask and the effect is only limited to the masked area. most of the time the masked area is ignored and the effect is applied to the whole image

  • Color Scheme Updates Not Working

    Color schemeing is hugely helpful for me. I recently migrated from a Win7 machine to a Mac and have been trying to change the color scheme. I uploaded a dark scheme I found, that worked okay, but when I go in to make some additional tweaks, they simply don't save. I'll make the change > click OK > go back go the Preferences menu, review the change I made, but it won't show. As if the change didn't happen at all.
    Quit the app after making the change doesn't seem to really help either.
    Anyone experience anything like this?
    Thanks!

    I may be a little confused, but if you are working with a gray or white layer the color burn will not work as there is no color to work on. Does that make sense?

  • Color Highlights does not work for chart

    When I set the color coding in the chart, it works fine if I run the crystal report on the same DB that I use to design the report.
    Problem occurs if I run the report on another DB. Color Highlights does not work in that case.
    I am using JRC to run the reports.
    Thanks & Regards,
    Amrita

    Hi Jehanzeb,
    In chart expert there is a tab "Color Highlightsu201D. In this tab one can specify the condition based coloring.
    In my case I want to show "RED" color for Unauthorized events andu201D GREEN" color for Authorized Events.
    While creating a report suppose I am using a database server "DB-A".I set the color highlights in the chart as I explained. Please be noted that when we click on the color highlights tab it asks for the database login.
    To view the report we have our own server and we are using JRC APIs.
    Hence I map my report with server and try to view the Report. My Server is connected with database "DB-B" which is different from the database I used to create the report.
    This time color Highlight I have specified while creating the report does not work.
    I have tried using the "Format Series Riser" option. But the problem with this is that, it does not color the chart conditionally.
    I mean if I give GREEN for Authorized and RED for Unauthorized. It gives the green color either to Authorized or Unauthorized which so ever occur first in the chart.
    For example:-suppose there is no Authorized Event on date 15-Jan-2009 and I select the date range starting from 15-Jan.In this case Unauthorized event is the first to print on the chart hence this event get the green color though I expect this events to be in RED color.
    Regards,
    Amrita

  • IMovie 10.0.1:  Stabilization doesn't work.  I have tried several times, it just grays out.  Also, fonts, font size, color of title not working.  What's the skinny?

    IMovie 10.0.1:  Stabilization doesn't work.  I have tried several times, it just grays out.  Also, fonts, font size, color of title not working.  What's the skinny?

    PROBLEM SOLVED!
    I went to my device manager on my Windows 7 PC and found the Bonjour service in my Services and Applications section. I set it to manual and BANG iTunes started working like it's supposed to.
    Unfortunately, I let my IPad get stolen on 17 Jan so I'll probably wait until after April to replace it with an IPAD 2!

  • Desk jet 4280 all in one - black ink not working

    I have a new blank ink cartridge with full ink level. Black photocopying does not work but colour does. I have tried resetting and restarting printer and removing and reinserting cartridge.
    Black printing from computer does not work either.
    Any suggestions? Thanks so much!

    Hi @Banana65 
    I would like to help you with the your black print quality. Please use the following document to troubleshoot the issue; Faded, Missing, or Dull Colors in Printouts.
    If the issue remains unresolved after following all of the steps in the link above, I recommend contacting HP.
    Don't hesitate to call, although the printer may be out of warranty, the cartridges could be in warranty; therefore, there wouldn't likely be a fee for the phone support. HP will, at HP's option, either replace products under warranty that prove to be defective or refund the purchase price.
    They could even determine after troubleshooting that it is a problem with the printer, in which case they may offer you a discount on a newer model.
    The number to call HP is 1-800-474-6836 for Canada and US, or you can Contact HP Worldwide.
    To find the “Warranty Ends” date, look in the following table for the date's location on each product. The date follows the YYYY/MM/DD or YYYY/MM format, where YYYY indicates the year, MM indicates the month, and DD indicates the day.
    I hope this helps.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Color Context does not work properly

    Hi,
    I'm using MII 12.1
    ColorContext does not work properly with Lights and Multilights. I did not test other grids.
    For every match it shows black colored lights.
    Is there a way to solve this problem?
    Thanks.

    Cemil,
    There was a bug in the early versions of 12.1 for color contexting.  Color context changes were made in the display template were not being saved.  I would strongly urge you to upgrade to SP5 patch 1.  However, if you want a very crude way to test if your contexting is working the way you want it to:
    1. Export your display template
    2. Find the color context section of the xml and change the settings to the desired color coding
    3. Import your modified display template
    4. Test
    I do not recommend this as a short term or long term solution.  It is a hack and should be recognized as such.  But it will allow to test your configured display template's behavior.
    Regards,
    Mike

  • Hp laserjet 100 color mfp m175nw not working anymore – MAC OSX YOSEMITE

    After installing the YOSEMITE update my hp laserjet 100 color mfp m175nw not printing anymore. Connection is USB. And OSX Drivers are all up-to-dae. Also i heared similar problems with other printers than HP.
    Any help? Thanks alot.

    Hi @Ankanb ,
    I understand that you are having issues since the Apple Security Update was done on the computer, after  uninstalling and reinstalling the software, you can't find the printer now.  I would be happy to help you.
    I have provided some steps to try, to see if we get the printer working again over the network.
    Print a Configuration page to see if the printer still has a valid IPv4 address.
    Printing a Configuration Report.
    If you have a valid IPv4 address for the printer then try and access the Embedded Web Server for the printer.
    Type the IP address into your web browser's address bar. (Safari)
    Did it load the webpage?
    Repair the Disk Permissions on the Mac:
    Close all applications.
    On the Apple menu bar, click Go, click Applications and then click Utilities.
    Double-click Disk Utility.
    Highlight your hard drive/partition on the left.
    Click Verify and then Repair Disk Permissions.
    Restart the computer..
    Reset the Printing System:
    Note: This will remove all printers in the print and Fax/Scan, any printer removed can be re-added later by clicking the plus (+) symbol.
    Click the Apple icon and then click System Preferences.
    Click Printers & Scanners.
    Right-click (or Ctrl +click) in the left white side panel, then click Reset printing system.
    Click OK to confirm the reset.
    Type the correct Name and Password.
    Click OK to reset the printing system.
    Then click the + sign to add the driver, highlight the printer. (you might have to click the drop down to select the printer's name) Then click on the Add button.
    If you are having network issues, then add the printer through the IP Protocol.
    After clicking the + button, select the IP icon across the top, type in the printer's IP address, select jet direct below and then Apply. (you won't be able to scan but you will be able to print, this way we will know if it is a Multicasting issue, if the Mac sees the printer)
    If the Multicasting is turned off on the router, you won't be able to add the printer as a bonjour device.
    Test the printer.
    How is the printer connected?  (Ethernet/Wireless)
    If there is anything else I can help you with, just let me know.
    Have a nice weekend!
    Thank You.
    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" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • Color management does not work as expected, different from v3.6

    Color management seems to work differently than FF 3.6.
    On a home page, I have a background graphic that is supposed to blend into the page background. I have left that graphic untagged so the blending will work in all browsers regardless of color management. This works fine in IE, Safari, Chrome, and Firefox 3.6 in all color management modes.
    In default mode 2 in v3.6, the graphics is not color managed because it is untagged. The page's background is left as is, and things blend perfectly. In mode 1, full color management, the graphic is assumed to be srgb and is color managed, and the page's background color seems to follow.
    In Firefox 4, using mode 1 creates a mismatch between graphic and background, as if this time only the graphic is color managed and not the rest. This is bad because it now creates a situation where we cannot be sure that there will be a match.

    A good place to discuss issues with Minefield 4 nightly builds and Firefox 4.0 beta builds is at the mozillaZine Firefox Builds forum.
    You need to register on the mozillaZine forum site in order to post at that forum.
    See http://forums.mozillazine.org/viewforum.php?f=23

  • Color picker tool not working after upgrading to Lightroom 6.0I

    I had Lightroom 4.4 and I upgraded to Lightroom 6.0.1.
    mine is a standalone version and not creative cloud version
    After upgrading, color picker tool is not working properly.
    I am unable to pick color from image

    Hi dheerajm35482857,
    It seems that turning off CPU in preferences solves the problem, see: LightRoom 6 color picker bug.

  • Background color code is not working. Please help

    I am trying to add a background color to a page.
    But the background color is not showing.
    What I am doing is adding, using just as an example pink:
    bgcolor: pink;
    to the style section.
    Here is a simplified version of the code. It just uses the
    letter "a repeated for where there is much more text:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    p.MsoNormal {
    margin:0cm;
    margin-left: 30px;
    margin-bottom:.0001pt;
    bgcolor: pink;
    font-size:12.0pt;
    font-family:"Times New Roman";
    </style>
    </head>
    <body>
    <p class="MsoNormal"
    style="text-autospace:none;"><span style="font-family:Geneva;
    color:black; "> </span></p>
    <p class="MsoNormal"
    style="line-height:14.0pt;text-autospace:none;"><span
    style="font-family:'Arial Black'; font-size:14.0pt; ">aaaaaaaa
    aaaaaaaaa aaaaa aaaaaa</span></p>
    </body>
    </html>
    What am I doing wrong?

    >> What am I doing wrong?
    1. Using improper CSS syntax as Ken pointed out.
    2. Using code from MS Word (p.MsoNormal).
    3. Using physical units of measure in your CSS for an
    on-screen document
    (pt, cm)
    4. Using an invalid CSS property (text-autospace)
    Walt
    "pppp145pp" <[email protected]> wrote in
    message
    news:gg7vf7$nba$[email protected]..
    >I am trying to add a background color to a page.
    >
    > But the background color is not showing.
    >
    > What I am doing is adding, using just as an example
    pink:
    > bgcolor: pink;
    > to the style section.
    >
    > Here is a simplified version of the code. It just uses
    the letter "a
    > repeated
    > for where there is much more text:
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    > "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="
    http://www.w3.org/1999/xhtml">
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
    > <title>Untitled Document</title>
    > <style type="text/css">
    > p.MsoNormal {
    > margin:0cm;
    > margin-left: 30px;
    > margin-bottom:.0001pt;
    > bgcolor: pink;
    > font-size:12.0pt;
    > font-family:"Times New Roman";
    > }
    > </style>
    > </head>
    >
    > <body>
    > <p class="MsoNormal"
    style="text-autospace:none;"><span
    > style="font-family:Geneva; color:black;
    "> </span></p>
    > <p class="MsoNormal"
    style="line-height:14.0pt;text-autospace:none;"><span
    > style="font-family:'Arial Black'; font-size:14.0pt;
    ">aaaaaaaa aaaaaaaaa
    > aaaaa
    > aaaaaa</span></p>
    >
    > </body>
    > </html>
    >
    > What am I doing wrong?
    >

  • Eye Dropper Tool (Color Picker Tool) not working correctly - Premiere CC - Windows 8 - Multiple Displays

    I'm running Windows 8, Premiere CC 2014 with two monitors. The eye dropper tool (color picker tool) isn't working correctly. It is selecting colors that are not the colors being hovered over. I've reasearched and see solutions to the problem when occurring with Mac, but do not see a solution for Windows. When I disconnect the second monitor, the eye dropper tool works correctly (as described by Mac users). I deleted any profiles for the montors that weren't the same, and still having the issue. I've also tried putting the source monitor on the second monitor, and tried sampling color from there... same result.

    Hello All,
    Problem solved...I reset all tools in the Tool Preset window. Seems to be working.
    Hope this helps someone...
    Cheers!

  • Black ink not working after my computer did an update (2 new cartridges put in)

    Black ink stopped working suddenly.  Tried 2 new cartridges and they did not work.  Since the day before their was an automatic 'updates' on my computer I thought it was that, but making copies doesn't work either.  I already cleaned the print heads with still not even a hint of black ink coming out.
    Usually, when the ink gets low it will be light at first or streaky . . . not just none at all.  Could the update been a problem?

    The update is likely not related.  I would suggest going through the troubleshooting steps in the document here.   Be sure especially to check the vents as shown in solution six.  If the steps there do not resolve the issue soaking the printhead as shown in the post here may help.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • W530 Color management does not work

    I just received a W530 to replace a W520 from lenovo.  I've loaded my monitor profiles that I've been using on the W520 into the proper directory on system32.  Using the color management control panel I've set up the w530 identically to the W520, however, when I load and select different profiles for my monitor, and make them the default, nothing happens, the monitor remains the same.  This happens even loading completely wrong profiles that would make the monitor look terrible if they loaded.  On the W520 selecting profiles and making them the default under the color managment control panel works properly.
    Any suggestions would be very welcome at this point.  The display bios settings are identical on both machines, as are the settings for the monitor under the advanced tab.

    I solved my own problem, with a helpful post getting me to the (not so obvious) screen to select windows management for color:
    http://forum.notebookreview.com/lenovo/675361-w530-owners-thread-36-print.html
    thanks to the poster - Flicster

  • Color Management Does Not Work in AE

    I color manage everything I do in Photoshop and Lightroom without a hitch.
    After Effects CS5 does not color manage correctly.  It simply does not work.  The only setting I could find for it simply asks if you want it more accurate.
    Maybe there are other settings somewhere, but I have not found them.
    Is there anyone out there that really understands color management that is having the same problem?

    I want to be able to see on my wide gamut monitor during AE preview, what I see in Photoshop.  I work with stills and thought that AE would simply allow me to view my stills based on my color profile.
    AE will recognize embedded color profiles, but you still need to tell it how to retain or convert them by setting up the project color space in the project options and assigning a preview (proof) profile to your comp (your monitor profile in this case) and depending on what other stuff figures in, you may need to deal with the linearization options and Gamma overrides or manually apply a color profile converter effect. Anyway, depending on what you are after and where you plan to use your resulting video, none of that may make sense and you may be tackling the problem from the wrong end. If your files are going to end up on a DVD, BluRay or as a Flash video on the web, extensive adjustments using your own profiels won't do any good, as color spaces and target profiles for specific video formats are fixed. So in fact you may need to spend time to adjust your imagery to work without color profiles or the standard sRGB profile at least....
    Mylenium

Maybe you are looking for

  • Unattended Install - Lightroom 5.7.1 (Creative Cloud)

    Hi all, I might have missed something here but after creating a Creative Cloud package, I install the MSI that was created inside the "Build" folder followed by running the ExceptionDeployer in the Exceptions folder. However, the issues are: Public d

  • Error of New report creation in BAM Active Studio

    I just installed Oracle BAM. I entered in WEB-interface and selected Active Studio. Then I pressed "Create a New report" Button. I've had the following message report: The Data Object was deleted. What shall I do to fix this problem? The error detail

  • Server load calculation on CSS

    With a CSS, according to the documentation, the service load is based on the time it takes to complete a flow from SYN to FIN. Unfortunately, this doesn't represent the load on the server (for our application at least) as it takes very little time to

  • Conditional Branch Execution?

    OK, Newbie here (and a bit frustrated). First application in the works. I have 2 ways to get to a page. When I click on the "Create" button, I want to return to the page that called the current page. Call them pages 1, 2 and 3. The default branching

  • Flash player stutters for 1 second then continues normally

    Hi all, Problem is very weird. I have Mozilla Firefox, IE, latest flash (11.9), Win 8.1 All latest updates. Online video playback with flash player stutters in a very weird way - even if video is fully downloaded it stutters for a second irregulary a