A problem changing applet's background colour

Hi there,
I'm hoping somebody can help me with what I believe to be a problem I have in changing the background colour of an applet, the source code of which is posted below. If super.paint(g); is commented out, the background of the applet will be changed to whatever colour is specified, however if it is not the background will remain grey. As I understand though, super.paint(g); should be part of the program. What am I doing wrong? Should super.paint(g); in this example be part of the program?
Before posting this I searched the forums and looked at some of the Q's & A's about changing an applet's background colour but am non the wiser.
Thank you for your help.
Regards,
THE_TH1NG
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
public class Calculate extends JApplet
public Calculate()
//Variables used in our calculations.
double sum; // Add the two numbers
double product; // Multiply the two numbers
double quotient; // The first number divided by the second number
double difference; // The first number minus the second number - This may result in a negative value being returned
double userInput1; //Stores the first number as a double after being converted from type string
double userInput2; //Stores the second number as a double after being converted from type string
public void init()
String number1; // The first number to be entered by the user
String number2; // The second number to be entered by the user
number1 = JOptionPane.showInputDialog("Please enter the first floating point number"); // The user inputs the first number as a string
number2 = JOptionPane.showInputDialog("Please enter the second floating point number"); // The user inputs the second number as a string
// Convert the user's input from type string to type double
userInput1 = Double.parseDouble( number1 );
userInput2 = Double.parseDouble( number2 );
// Perform the calculations
sum = (userInput1 + userInput2);
product = (userInput1 * userInput2);
difference = (userInput1 - userInput2);
quotient = (userInput1 / userInput2);
public void paint( Graphics g )
//The applets background will be set to the desired colour if super.paint(g) is commented out
//But the background will remain grey if the code is not commented out.
//What am I doing wrong?
//super.paint( g );
setBackground(new Color(50,150,255)); //Light Blue
g.drawRect(10,10,250,100); // Draw a rectangle 250 pixels wide X 100 pixels high to enclose the rest of the program's output
//Dispaly the results of the calculations to the user
g.drawString( "The numbers entered are " + userInput1 + ", " + userInput2, 25, 25);
g.drawString( "The sum is " + sum, 25, 40);
g.drawString( "The product is " + product, 25, 55);
g.drawString( "The difference is " + difference, 25, 70);
g.drawString( "The quotient is " + quotient, 25, 85);

You could try defining
public void update(Graphics g) {
    paint(g);
}That's the only difference I see between your code and my applet code. If that isn't it, you could try getContentPane().setBackground(...) but I don't know how that could make much difference (I would think that the content pane is transparent...)
Another possibility is that, if you're using Swing, you probably shouldn't be overriding paint() and should stick to the paintComponent() method or whatever is appropriate.

Similar Messages

  • Change the desktop background colour of Acrobat 9 Professional?

    Is it possible to change the desktop background colour in Acrobat 9? The reason I ask is we are supplied newspaper ads and sometimes they have a black keyline on the border of the PDF.
    The dark background on the desktop can make it difficult to see a fine keyline. We were previously using Acrobat 7 Professional which had a white background.

    Doesn't work
              ^                                                                                    ^
    Obviously, I can't, in this particular screenshot show everything.
    This is what the fellow is talking about.  Naturally if his keyline item is in Black it ain't going to show up  In Acrobat previous to 9 all this back Ground was grey.

  • How do you change the slide background colour in the keynote app?

    How do you change the slide background colour in the keynote app?

    You can't (not in Keynote for iOS). The background color is a function of the template selected when you create the file initially and cannot be altered. the only workaround I know of is to add a graphic file to the slide and position it behind all other content, but this would need to be repeated on any slide you wish to "recolor".

  • Change 'Elegant Brochure' background colour

    Hi there,
    Making a brochure for our wedding (using the option under brochure of 'Elegant Brochure') to go along with the invites. Is there any way we can change the brown background colour to match our wedding's black, red and white theme colour while keeping the pattern in the original colour scheme? Basically just want to change the brown background to a light red.
    Thanks for your help.
    Message was edited by: Cheeky Whitey

    Click on the panel. Note the little Xs? That means it’s locked. In the Arrange menu choose unlock. Because the panel is a JPEG instead of a shape, bring up the Adjust Image pane and use the various sliders to produce the color you want. It might be a good idea to Lock them again after you change the color.
    Walt

  • Cannot change datagrid item background colour dynamically

    Hello, I am trying to change the background colour of a data
    grid item dynamically.
    I am using a component for each item with the item_renderer
    function
    then in the component this is the line i am having trouble
    with
    <mx:Canvas width="100%" height="100%" id="item_bg"
    backgroundColor="{data.status_colour}">
    data.status_colour is definatly set and has a hex value,
    #FF99CC for example
    i tried
    <mx:Canvas width="100%" height="100%" id="item_bg"
    creationComplete="item_bg.setStyle("backgroundColour","{data.status_colour}")">
    it did put colours on the but they were all in the wrong
    place, so a completed item should be green but it is coming up with
    red (failed)
    any ideas??
    thanks

    You will need to use a custom calculation script, something like:
    // Custom calculation script
    (function () {
        // Get the field values, as numbers
        var v1 = +getField("Severity1").value;
        var v2 = +getField("Likelihood1").value;
        // Calculate the product
        var prod = v1 * v2;
        // Set this field's value;
        event.value = prod;
        // Default background color
        var bg = color.white;
        // Define the orange color
        color.orange = ["RGB", 1, .33, 0];
        // Determine background color based on the product
        if (prod >= 1 && prod <=5) {
            bg = color.green;
        } else if (prod > 5 && prod <= 10) {
            bg = color.orange;
        } else if (prod > 10) {
            bg = color.red;
        // Set this field's background color
        event.target.fillColor = bg;

  • How can I change the sms background colour?

    just upgraded to IOS7 on my Iphon 4s...don't like the over-bright white background on sms....how can I change the background colour for text messaging?

    There is no option to change the background color in the  messages app, other than selecting settings>general>accessibility>invert colors, but this changes the colors of everything.

  • Changing Slide Show Background Colour

    Being a newbie to this forum, I am not sure if this has been asked before, if so I apologise in advance.
    I have set my site up using the black background as it is a photography related site and the black lends itself well to the photographs.
    Is there a way of changing the parameters of the slide show to change the background colour from white to black ?
    Any help appreciated.
    Anton

    I guess you are not publishing to .Mac
    Here are some alternative slideshows for non-.Mac publishing (with black backgroudns)
    http://www.codemanic.com/blog-archives/000084.html
    http://discussions.apple.com/thread.jspa?messageID=4526950#4526950

  • How do I change the message background colour in mail,(2013)?

    I'd like to be able to do this.
    I send a lot of photos,(for my biz as an art photographer), and they would present FAR better on aa grey or black background than on the harsh and glaring white background.
    I haven't figured out how to create a coloured background template for the Stationary plug, or that might be an option.
    Any assistance would be greatly appreciate!

    You can't do that, but you can change the visual properties of the display by selecting Apple menu > System Preferences > Displays > Color > Calibrate...

  • Why does my footer background colour change when adding a float to a DIV element?

    Bear with me as I am a student learning dreamweaver....
    I am trying to insert a series of 4 DIVs into a footer area with a black background. WHen I insert a float to constrain them to a horizontal position, the black background disappears and the body background shows through. A strip of the footer displays on top of the area where the DIVs are placed. The float works but the problem is with the background colour. It's almost as if the divs have been pushed down below the footer area. I have tried placing my cursor in several locations before inserting the float but it doesn't change anything.
    Can anyone help?

    It all depends on the code you're working with.   In the following example, I applied overflow:hidden to the <footer> element. 
    Copy & paste this code into a new, blank HTML page to see how it works.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 Layout</title>
    <style type="text/css">
    body {
        font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
        background-color: #CCC;
        padding: 0;
        color: #000;
        width: 1000px;
        margin: 45px auto;
    header {width: 100%; display:block; background: #A5C9C9; min-height: 100px}
    section {width: 100%; display:block; background:#FFF; min-height: 300px}
    footer {width: 100%; display:block; background: #FF9; overflow:hidden;}
    aside {width: 22%; float:left; display:block; margin-right: 4%; background:#D8E9B6; min-height: 200px;}
    aside:last-child {margin-right:0}
    </style>
    </head>
    </body>
    <header>
    <h1>Content for header goes here</h1>
    </header>
    <section>Content for section goes here</section>
    <footer>
        <aside>aside 1</aside>
        <aside>aside 2</aside>
        <aside>aside 3</aside>
        <aside>aside 4</aside>
    </footer>
    </body>
    </html>
    Nancy O.

  • ITunes 11 how can the window background colour be changed from white to black in Grid View?

    How do I change the window background colour ,in Grid View, from the new, default, white back to the good old, more easy on the eye, black?
    Apple did this to us in iPhoto some time ago and had to add a preference for shades of grey other than white. Why didn't Apple learn from this mistake?

    It is good to know I am not alone. The first thing I did after downloading iTunes 11 was go into preferences to change the background color. But alas, the option for a dark background is gone. I also was kind of disappointed in the lack of ability to resize the artwork, but not to the extent of some other commenters here.
    I will say this though. I love the way the albums expand with custom colored backgrounds based on each album's artwork colors. This looks fantastic. Still it would be nice to accomodate those who prefer to use a dark background for the overall application's theme.
    So, Apple, I join with my fellow users in requesting the return of resizable artwork, and the option for at least a dark (or an even further customizable) background color for the overall theme of the application. Thanks!
    Godspeed,
    Nuckels

  • Is there a way to change default background colour?

    Hi,
    I am frequently embedding U3D files into adobe acrobat and every time I need to manually change the "default" background colour from grey to white in the Show Advanced Options tab of the insert 3D dialog box.
    Is there a way to permanently set the default background for all inserted 3D files to white instead of the grey default?
    Thanks!

    No.

  • How to change background colour?

    Hi
    I have an image with a statue and different background colours. I want to change the complete background colour around the statue in one colour for example white. I tried several times but it doesnt work. Do you have a suggestion?
    Thx
    Dom

    Hi Dom,
    You've asked about a technique that many beginner Photoshop users want to learn. The challenge is that this technique requires learning a few tools and skills before you start. I would recommend the following:
    1. Learn about how to make selections. Here is an image with the blue background selected. Here's a  video about making basic selections.
    2. Learn about layers and masks and how they work. Below is the same image with the blue background hidden. This video teaches the basics about the Layers panel.
    3. Create a new background layer to replace the old one. Below is the image with a new solid white background on the layer below the original statue layer.
    Once you've learned about selections and layers, try following the technique Russell Brown uses in the video below to create a simple selection of the current background and hide it by using a layer mask. Once the old background color is hidden by the layer mask, the layer beneath is revealed and it replaces the old background.
    Good luck with your project! I hope this helps.
    Luanne

  • Changing Background Colours

    I am in the process of writing a package and want the end
    user to be able to pick their own background colour (Within reason)
    For my sins I used the getfileproperty and setfileproperty
    whilst writing the package but they don’t work with a
    published package.
    I have also tried drawing a box and changing that colour, but
    would still prefer to change the package background colour.
    How do you change the background colour?

    If I remember right there's no way to change this at runtime.
    Only solution
    I can think of is your box in the background idea, setting
    the box to a
    layer that will keep it below anything else. Also you need to
    attach a
    calculation to the display that sets movable:=false
    Mike
    ====================
    Mike Baker
    Adobe Community Expert
    mike-baker at cox dot net

  • Flash CS4 - Background Colour Change Not Changing in Test Movie

    Hello,
    Whenever I change the document's background colour in Flash CS4 and then "test movie", the background colour remains white. However if I publish it the colour will be the selected colour.
    It's not a huge deal since it publishes right, but I'd really like to be able to test my movie with the correct background colour.
    I'm on Mac OS X 10.6.8, and I am updated to the latest version of CS4.
    Any help would be greatly appreciated,
    Thanks

    Hey there,
    Could you describe the setup or link a file with the problem?  I can't reproduce the problem with basic fades (obviously they should continue to work when you switch the player).  Is it just in the document you're working on, or all documents you create?
    Thanks,
    Jen.

  • Change background colour for iTunes 9 (70) on Mac OS 10.5.8

    I want to change the background colour from white to black on iTunes 9 (70). When i tried using the iTunes preferences General Tab I did not get the option available to change the background colour.I tried looking for software updates as maybe iTunes 9 (70) is out of date but my Mac told me there weren't any!
    This feature would be very useful to a friend of mine who is registered blind so any help would be appreciated lots. Thnx.

    Thank you, that download installed without a problem. It also installed Safari 4.0.2, which still had to be upgraded to 4.0.3. Now iTunes 9 is happy and can access the iTunes store, so I can get my Podcasts again.
    Life is good.
    Thanks,
    Mark

Maybe you are looking for

  • Install of 9201 on Solaris 9

    I am getting this same error on install of 9201 on Solaris 9 ; ld is core dumping - I have all of the required packages so I can't figure out why linking is failing, can anybody please give me a fix?!!? Calling action unixActions2.2.0.6.0 make instal

  • Trouble with interactive PDF made on MAC not working on PC

    I am making an interactive PDF which will be sent out to many people. The PDF has links which open other PDFs. These all work perfectly on the Mac. When on a PC half open half dont. I dont know much about PCs at all, they are using acrobat V9 pro. Ha

  • Quick start Key Question ( S10-2)

    When I first used the Quick Start key after the normal boot up of windows OS, a config screen appeared, wherein I could choose 1) one Application, 2) One Folder or File and  3) an URL for quick launch. After I chose one URL, it disappeared never to r

  • Add records to workflow in Resultset iview

    Hi, Is it possible to add record(s) to a MDM workflow using MDM Result set iview? Best regards, Arun prabhu S

  • Why do I keep getting this error and how do I make it stop?

    Problem Event Name:          APPCRASH   Application Name:          iTunes.exe   Application Version:          10.5.0.142   Application Timestamp:          4e9243f2   Fault Module Name:          rlls.dll_old_unloaded   Fault Module Version:          0