Gray applet background

This question as been posted numerous times, but noone one has provided a solution that works.
It has to do with getting rid of the infamous gray background when initially loading an applet.
the setbackground() function only changes the background after the applet has loaded. I know that this can be done because I have seen applets that show a different color other than gray.
Any ideas anyone?

weel, not very sure but :
1. as applet is not already loaded, it is normal that setBackground doesnot do anything.
2. are u sure that is not a functionnality of the current browser/jvm used?
3. how about dealing with DIV (put a DIV on foreground with some img bg while applet s not loaded then hide this DIV)?
what do u think about this?

Similar Messages

  • What do you think of the gray linen background?

    Apple has always been known for cool design. I'm surprised at the dull appearance of the gray linen background behind the login screen. What do you think of it? I know there is a hack for changing it, but perhaps if enough people complain, Apple could provide some easy to configure alternatives.

    To each his/her own, but this is something I couldn't care less about. I'm at the login screen just for a second or two - to enter my password to login.

  • Gray color background in PDF exported from Crystal Report not printing correctly in Digital Printer (CMYK)

    I am processing a crystal report on RAS server,and exporting it to PDF, using the RAS Dlls.
    Dim Report As ReportClientDocument
    Dim crExportData As New ByteArray
    Dim crExportType As CrReportExportFormatEnum
    crExportType = CrReportExportFormatEnum.crReportExportFormatPDF
    crExportData = Report.PrintOutputController.Export(crExportType)
    A gray background is applied to an object in crystal report, with RGB color code (216,216,216).
    On exporting this report to pdf, the color appears as required.
    However, when printing this PDF in a digital printer (uses CMYK color format), the color changes to Pinkish Gray.
    The color remains gray as required, in other printers.
    Is there any way to make the exported PDF CMYK compliant?
    Please help.

    From the info, I have no idea what version of .NET and CR you are using...
    How is the printing from the CR designer?
    How is the printing to another printer, say HP?
    Do you have the latest updates for Digital Printer (CMYK) installed?
    How does a plain pic with grey background print from a .NET app? (E.g.; is this a CR issue, or a framework issue? See:
    RGB to CMYK (Plugin) - Plugins - Publishing ONLY! - Paint.NET Forum
    RGB VS. CMYK: WHEN TO USE WHICH AND WHY - Crux Creative
    http://www.sumydesigns.com/2012/12/06/color-rgb-vs-cmyk-web-color-vs-print-color/
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
      Follow us on Twitter

  • Java Applet Background Color Problem on Internet Explorer

    Hi,
    Please check out the following URL:
    http://www.utopiainteractive.com/clients/AkonFinal/glossary.htm
    The menu bar is writting in Java Applet. If you scroll down the page, and scroll back up, I see white background as I scroll back up. It happens only on Internet explorer. Neither Java Applet nor HTML Body bg color is white. I am kinda lost, and any help would really be appreciated.
    Thank you and look forward to hearing from someone soon.
    Sachin

    Hi,
    Well I used HtmlConver utility to generate applet html code, so I assume nothing is wrong with Object tag. Do you know what could cause this problem on Internet explorer? To be honest, I spent last couple of days, but I am just lost. It absolutely works fine on Netscape.
    Thanks,
    Sachin

  • Applet background color

    Please help.
    In my code I have an animated applet, and I does work.
    I need a line of code to change the background colour to black - as it is currently white.
    Thankyou in advance anyone who helps in this matter

    Have you tried:
    setBackground(Color.black);
    in the init method of your applet?
    ;o)
    V.V.

  • Change applet background color with a button

    Does anyone know how to change the background of an applet by clicking a button within the applet? Thanks.

    Add an ActionListener to the button which calls the setBackground method.

  • Changing applet background

    hi i've created my applet successfully, but would now like to change it's appearance primarily so it isn't a grey square box.
    i've created an image to use as a 'background' (it does more than just change the colour) but when it loads up, the image over writes everything (except a canvas object i have that contains a graph). When i click the mouse over the blank areas some of the objects that should be displayed appear.
    how can i make the image go to the back ?
    I have added the image object using the paint method, is this where i have gone wrong?
    Thanks

    /*  <applet code="AWTBackground" width="400" height="300"></applet>
    *  use: >appletviewer AWTBackground.java
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    public class AWTBackground extends Applet
        public void init()
            BackgroundPanel background = new BackgroundPanel();
            GraphCanvas canvas = new GraphCanvas();
            BackgroundAction action = new BackgroundAction(background, canvas);
            setLayout(new BorderLayout());
            add(background, "Center");
            add(action.getButtonPanel(), "South");
        public static void main(String[] args)
            Applet applet = new AWTBackground();
            Frame f = new Frame();
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            f.add(applet);
            f.setSize(400,300);
            f.setLocation(200,200);
            applet.init();
            applet.start();
            f.setVisible(true);
    class BackgroundAction
        BackgroundPanel backgroundPanel;
        GraphCanvas graphCanvas;
        GridBagConstraints gbc;
        public BackgroundAction(BackgroundPanel p, GraphCanvas c)
            backgroundPanel = p;
            graphCanvas = c;
            gbc = new GridBagConstraints();
            backgroundPanel.setLayout(new GridBagLayout());
            backgroundPanel.add(graphCanvas, gbc);
        public Panel getButtonPanel()
            final Button
                showButton = new Button("show graph"),
                removeButton = new Button("remove graph");
            ActionListener l = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    Button button = (Button)e.getSource();
                    if(button == showButton)
                        backgroundPanel.add(graphCanvas, gbc);
                    if(button == removeButton)
                        backgroundPanel.remove(graphCanvas);
                    backgroundPanel.validate();
                    backgroundPanel.repaint();
            showButton.addActionListener(l);
            removeButton.addActionListener(l);
            Panel panel = new Panel();
            panel.add(showButton);
            panel.add(removeButton);
            return panel;
    class BackgroundPanel extends Panel
        Image image;
        int imageWidth, imageHeight;
        public BackgroundPanel()
            loadImage();
            setBackground(Color.black);
        public void paint(Graphics g)
            super.paint(g);
            int width = getWidth();
            int height = getHeight();
            int x = (width - imageWidth)/2;
            int y = (height - imageHeight)/2;
            g.drawImage(image, x, y, this);
        public void update(Graphics g)
            paint(g);
        private void loadImage()
            String fileName = "images/bclynx.jpg";
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.out.println("Bad URL: " + mue.getMessage());
            catch(IOException ioe)
                System.out.println("Unable to read image: " + ioe.getMessage());
            imageWidth = image.getWidth(this);
            imageHeight = image.getHeight(this);
        public Dimension getPreferredSize()
            return new Dimension(imageWidth, imageHeight);
    class GraphCanvas extends Canvas
        final int PAD = 15;
        public GraphCanvas()
            setBackground(Color.white);
        public void paint(Graphics g)
            super.paint(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            // ordinate
            g.drawLine(PAD, PAD, PAD, h - PAD);
            // abcissa
            g.drawLine(PAD, h -PAD, w - PAD, h - PAD);
            // line
            g.drawLine(PAD, (h - PAD)*3/4, w - PAD, PAD);
        public Dimension getPreferredSize()
            return new Dimension(250,125);
    }

  • Blinking gray desktop background and no dock/launchpad/mission control

    I just updated to Mountain Lion and my desktop background keeps changing from the picture to a gray screen. My dock also wont appear on the bottom of my screen and launch pad and mission control also do not work. I called Apple once and I reinstalled ML once already and its still doing it. Any suggestions?

    reboot, hold CMD+R .
    you'll be in the recovery partition.
    go to disk utility, and Verify and Repair your boot disk and its permissions.
    exit out of Disk Utility and then go to the area that says reinstall Mountain Lion.
    Do so.
    This will hopefully fix your issues.

  • Colour gray black background

    I know how to do to have the background in the window openings black and not dark gray, is it possiblle?
    Thanks a lot!
    Enrico

    Excellent point, too often overlooked.
    Fwiw, I like to use an immediately-perceivable difference in background luminance between the Viewer and the Browser so I can tell at a glance whether I am in a Browser or in a Viewer with many Images selected.
    All true grays are neutral in hue (that's the definition of "gray") -- which makes me wonder:  what does "neutral density" imply?  According to the Wikipedia article, "neutral" refers to having the same effect on luminance while leaving hue unchanged.  As such, "neutral seems to be a modifier of "filter" and not of "density".
    I was under the impression the 18% is the standard luminance for half-way between the normally experienced extremes of "dark" and "light".  I have always wanted to confirm this -- I settled on what I use above from trial and error (Viewer at 18%, Browser at 45%).  According to this Wikipedia article, middle gray, also called "18% gray", is equivalent to c. 46% luminance in the sRGB color space.  So for most users, setting the Viewer and Browser backgrounds to 46% (on a hardware calibrated display with fixed luminance settings) should give them the best perceptual results across a broad range of Images.  Agree?  Thoughts?
    Next time I calibrate my displays I might measured the Aperture Viewer and Browser backgrounds after calibration.  I'm still confused about the difference in the scales used for "18%" gray (18% of what?) and the sRGB gray of 46% (of what?).
    --Kirby.

  • Need to set applet background color

    Hi, I try to write an applet in java and I need to
    set the back ground color of my applet to
    ==> RGB ( 66 , 144 , 216 )
    how can I do that??
    I have already looked at Java API and couldn't
    such a method: setBackGroundColor(66,144,216);
    please help
    thanks

    import java.applet.*;
    import java.awt.*;
    public class Example extends Applet {
         public void init() {
              setBackground(new Color(66,44,216));
    }

  • Black and gray in background Acrobat 9?

    I try to hunt answer in acrobat furm (http://www.adobeforums.com/webx?128@@.59b72930)
    did you now how it's hapen?
    thank

    Now it is. :/ Check the Acrobat forum, as this is not a Color Management issue at all.
    Color Management is the intricate, critical process of gettin the image to match from capture to monitor and to print.

  • Removing gray crappy ugly Applet loader background

    excuse my language but I've spent the last two days tring to figure out how to remove the gray screen when the applet loads in a browser...
    I've searched the forums, found other ppl with same problem but no real solutions...
    from what I found:
    1. using javascript to hide the applet while its loading
    works for IE but not for Netscape 6( http://www.codeproject.com/java/javaappletwaitmsg.asp )
    2. using an applet to load the real applet
    seems ok, but you still see the gray screen when the first applet loads... basically this just shortens the time you get to see the gray screen, not a proper solution( http://www.acm.vt.edu/~jmaxwell/appletloader/appletloader.html )
    So should I assume there is no way to tell the java plug-in not to make the screen gray while its loading the applet??????
    WHY? WHY? WHY?
    is there really no way of changing this horrible GRAY screen???
    please if anybody found out how to solve this, post it here!

    2 main reasons why the gray panel stays for a long time..
    1, the JVM is loaded, the applet is now visible but due to lots of late binding and other startup stuff, the Applet itself takes a long time to load.
    Solution, in a previous page, load a dummy applet that does basically nothing and make it 1x1 pixels in width and height. This cuts down on the JVM start up.
    2, Your Applet causes classes to load from the Web Server (of course).
    Solution in 2 parts:
    Part 1, make sure that all your applet classes are jar'ed with compression on and that your applet code has debug code off and no optimisation used when compiling. This ensures the smallest code size other than that produced an obfuscator.
    Part 2, Your applet should be doing 2 things. Firstly, it should be attempting to turn its background to the chosen colour as soon as possible. It should be doing nothing else at all, not even creating other classes, loading classes nothing at all. Secondly, when the Applets background colour is set, then you can start loading classes that do the work your Applet is supposed to do. When that is all over, you can that start to modify the Applet's panel

  • 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.

  • Looking for Image Button Applet

    I'm looking for a simple image button applet (normal state, mouse-over and mouse-click) which can refer to a HTML or start a Javascript function. Can anyone help?
    Kippie

    Hi,
    This is the source code. I don't quite understand what I should do with the tokens. I hope this is allright. Thanks for your help
    Kippie.
    import java.net.URL;
    import java.awt.Color;
    import java.util.Vector;
    import java.util.Enumeration;
    import java.util.StringTokenizer;
    import java.applet.Applet;
    import java.applet.AudioClip;
    Program Name:     ImageURLButtonBar
         Author:               Paul Whitelock
         Version:          1.1
         Copyright:          (c) 1997 by Paul Whitelock and Modern Minds, Inc.
         Requires:          ImageURLButtonBar.class
                             ButtonBar.class
                             ButtonBarObserver.class (Interface definition)
                             ButtonRegion.class
                             ButtonAnimate.class
    Modifications: v1.01 (15 April 97)
                             *     Added "sticky" button behavior (controlled
                                  by applet "stick" parameter)
                             v1.03 (25 June 97)
                             *     Added applet parameter "useCodeBase". If useCodeBase
                                  is true, then image file locations will be based on the directory
                                  in which the Java class files are located. If useCodeBase is false, then
                                  the locations will be based on the HTML directory. Note that audio
                                  file locations are always based on the Java directory. The default
                                  for useCodeBase is false (use HTML directory for base).
                             *     The "stick" parameter will now accept a button number in
                                  addition to the value of "true" or "false". If a button number
                                  is specified, then that button will be "stuck" down
                                  when the button bar initializes.
                             *     Added the capability of loading multiple URLs for each button
                                  with an optional target for each URL.
                             v1.1 (25 September 97)
                             *     Added "baseBrighten" and "baseBrightenTint" parameters to control
                                  highlighting for base button bar.
                             *     Added "mouseOverBrighten" and "moBrightenTint" parameters to control
                                  highlighting for base button bar.
                             *     Added "mdBrightenTint" and "mdBrightenAll" parameters to control
                                  highlighting for base button bar. Previous versions of the applet
                                  supported "mouseDownBrighten," but only if button borders were not
                                  drawn for the button-down button bar (the "mdBrightenAll" can be set
                                  to "true" to override the this default behavior).
                             *     An "appletBGColor" parameter has been added to set the
                                  applet background color. The applet background color is
                                  sometimes visible during scrolling or during a page repaint.
         NOTE:               This source code was composed using Microsoft Visual J++
                             with tab stops of 4. Text may not be formatted correctly
                             if another editor is used.
         ******************************** PARAMETERS ********************************
              Applet Parm               ButtonBar Class Parm     Default Value
              ================== =======================     ==================
              appletBGColor
              disableBadURL                                        true
              mouseEnterAudio                                        null (audio disabled)
              mouseClickAudio                                        null (audio disabled)
              buttonDownAudio                                        null (audio disabled)
              stick                                                  false
         *     useCodeBase               base                         false (i.e., use getDocumentBase())
              orient                    barHorizontal               horizontal if applet width > height
              base                    baseBarName                    none - parameter REQUIRED
              mouseOver               mouseOverBarName          null
              mouseOver2               mouseOverBar2Name          null
              mouseDown               mouseDownBarName          null
              mouseDownOver          mouseDownOverBarName     null
              buttonsDisabled          buttonsDisabledBarName     null
              background               backgroundImageName          null
              barXPos                    barXBackgroundPos          0
              barYPos                    barYBackgroundPos          0
              buttonBorders          drawButtonBorders          ButtonBar.BORDERS_NONE
              borderColorTL          borderColorTopLeft          null (Color.white if error)
              borderColorBR          borderColorBottomRight     null (Color.gray if error)
              borderIntensity          borderIntensityPercent     50 (used only if borders)
              borderSize               buttonBorderSize          1 (used only if borders)
              downShift               downShift                    false
              downShiftAmt          downShiftAmt               buttonBorderSize
              baseBrighten          baseBrightenPct
              baseBrightenTint     baseBrightenTint
              mouseOverBrighten     mouseOverBrightenPct
              moBrightenTint          mouseOverBrightenTint
              mouseDownBrighten     mouseDownBrightenPct     
              mdBrightenTint          mouseDownBrightenTint
              mdBrightenAll          mouseDownBrightenAll
              buttonsDisabledDim     buttonsDisabledDimPct     25     (used only if no buttonsDisabled)
              grayBarBrighten          grayBarBrighten               0
              frameRate               frameRate                    150 (used only if mouseOver2)
         *     If useCodeBase is true, then all file locations are based on the Java class file
              directory (i.e., use getCodeBase()).
    public class ImageURLButtonBar extends Applet implements ButtonBarObserver {
         // Instance Variables
         ButtonBar buttonBar;
         Vector buttonURL = new Vector(10, 10);
         Vector buttonURLTarget = new Vector(10, 10);
         Vector buttonDescription = new Vector(10, 10);
         AudioClip mouseEnterAudio = null;
         AudioClip mouseClickAudio = null;
         AudioClip buttonDownAudio = null;
         // Applet Initialization
         public void init() {
              // =================================================================
              // Applet ImageURLButtonBar specific parameters
              // =================================================================
              // appletBGColor
              //          Set applet background color
              String parm = getParameter("appletBGColor");
              if (parm != null) {
                   try {     
                        setBackground(new Color(Integer.parseInt(parm, 16)));
                   catch (Exception e) {
                        reportError("appletBGColor");
              // disableBadURL
              //          If true, then any button with an invalid URL will be disabled
              parm = getParameter("disableBadURL");
              boolean disableBadURL;
              if (parm == null || !parm.equals("false")) disableBadURL = true;
              else disableBadURL = false;
              // mouseEnterAudio
              //          Sound to play each time the mouse enters any of the buttons
              parm = getParameter("mouseEnterAudio");
              if (parm != null) {
                   mouseEnterAudio = getAudioClip(getCodeBase(), parm);
                   if (mouseEnterAudio == null) reportError("Can't load " + parm);
              // mouseClickAudio
              //          Sound to play each time a mouse down click occurs in a button
              parm = getParameter("mouseClickAudio");
              if (parm != null) {
                   mouseClickAudio = getAudioClip(getCodeBase(), parm);
                   if (mouseClickAudio == null) reportError("Can't load " + parm);
              // buttonDownAudio
              //          Sound to play each time a mouse up occurs in a button (i.e, the
              //          button has be toggled through it's "down" position)
              parm = getParameter("buttonDownAudio");
              if (parm != null) {
                   buttonDownAudio = getAudioClip(getCodeBase(), parm);
                   if (buttonDownAudio == null) reportError("Can't load " + parm);
              // stickyBar
              //          If the "stick" applet parameter is "true", then buttons will stay
              //          "stuck" in the down position until another button is clicked.
              //          If the "stick" applet parameter is the number of a button in the
              //          button bar, then that button will be "stuck" down when the
              //          button bar initializes.
              int stickyBar = -1;
              parm = getParameter("stick");
              if (parm != null && !parm.toLowerCase().equals("false")) {
                   try {
                        stickyBar = Integer.parseInt(parm);
                   catch (Exception e) {
                        stickyBar = 0;
              // =================================================================
              // Class ButtonBar specific parameters
              // =================================================================
              // orient (barHorizontal)
              //          If this parameter = 'h' then the button bar is horizontal
              //          If this parameter = 'v' then the button bar is vertical
              //          If this parameter is not specified, then the button bar is
              //          horizontal if the applet width is greater than the applet height
              boolean horizontal;
              parm = getParameter("orient");
              if (parm == null) horizontal = size().width > size().height;
              else horizontal = parm.equals("h") ? true : false;
              // base     (baseBarName)
              //          The base image file for the buttons. This is the only image
              //          file that MUST be specified.
              String baseBar = getParameter("base");
              if (baseBar == null) {
                   reportError("Parameter 'base' REQUIRED!");
                   return;
              // barXPos (barXBackgroundPos)
              // barYPos (barYBackgroundPos)
              //          If a background image is specified then these to parameters
              //          represent the top-left corner location where the button bar
              //          should be placed on the background
              int barXPos = 0, barYPos = 0;
              try {
                   parm = getParameter("barXPos");
                   if (parm != null) barXPos = Integer.parseInt(parm);
                   parm = getParameter("barYPos");
                   if (parm != null) barYPos = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("barXPos or barYPos");
                   barXPos = barYPos = 0;
              // buttonBorders (drawButtonBorders)
              //          "none" = do not draw any button borders
              //          "all"     = draw borders around all button bar buttons
              //          "base"     = draw borders only around buttons on base button bar
              //          "other"     = draw borders around all button bar buttons EXCEPT base button bar buttons
              parm = getParameter("buttonBorders");
              int drawButtonBorders = ButtonBar.BORDERS_NONE;
              if (parm != null) {
                   if (parm.equals("base")) drawButtonBorders = ButtonBar.BORDERS_BASE;
                   else if (parm.equals("other")) drawButtonBorders = ButtonBar.BORDERS_OTHER;
                   else if (parm.equals("all")) drawButtonBorders = ButtonBar.BORDERS_ALL;
              // borderColorTL (borderColorTopLeft)
              // borderColorBR (borderColorBottomRight)
              //          Normally, borders are drawn around buttons by lightening or darkening
              //          the image in the border region. A specific color can be used instead
              //          for the top and left borders and/or the bottom and right borders. The
              //          value specified for either of these two parameters should be a hexadecimal
              //          number (e.g., "FF0000" for red, "888888" for medium gray, etc.).
              Color borderColorTopLeft = null;
              Color borderColorBottomRight = null;
              try {
                   parm = getParameter("borderColorTL");
                   if (parm != null) borderColorTopLeft = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("borderColorBR");
                   if (parm != null) borderColorBottomRight = new Color(Integer.parseInt(parm, 16));
              catch (Exception e) {
                   reportError("borderColorTL or borderColorBR");
                   borderColorTopLeft = Color.white;
                   borderColorBottomRight = Color.gray;
              // borderIntensity (borderIntensityPercent)
              //          If borders are drawn for buttons, and if a border color is not specified
              //          (see above), then the image in the border region will be lightened or
              //          darkened by this percentage to create the borders.
              int borderIntensityPercent = 50;
              try {
                   parm = getParameter("borderIntensity");
                   if (parm != null) borderIntensityPercent = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("borderIntensity");
                   borderIntensityPercent = 50;
              // borderSize (buttonBorderSize)
              //          The size of borders, if borders are specified.          
              int buttonBorderSize = 1;
              try {
                   parm = getParameter("borderSize");
                   if (parm != null) buttonBorderSize = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("borderSize");
              // downShift
              //          If true, then the button image is shift down and right downShiftAmt
              //          (see below) pixels when the mouse is clicked on the button.
              parm = getParameter("downShift");
              boolean downShift = (parm == null || !parm.equals("true")) ? false : true;
              // downShiftAmt
              //          If downShift is true, then the button image is shift down and right
              //          downShiftAmt (see above) pixels when the mouse is clicked on the button.
              int downShiftAmt = buttonBorderSize;
              try {
                   parm = getParameter("downShiftAmt");
                   if (parm != null) downShiftAmt = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("downShiftAmt");
              // baseBrighten (baseBrightenPct)
              //          The base bar will be lightened by this percentage
              int baseBrightenPct = 0;
              try {
                   parm = getParameter("baseBrighten");
                   if (parm != null) baseBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("baseBrighten");
              // mouseOverBrighten (mouseOverBrightenPct)
              //          A button will be lightened by this percentage when the mouse
              //          moves over a button.
              int mouseOverBrightenPct = 0;
              try {
                   parm = getParameter("mouseOverBrighten");
                   if (parm != null) mouseOverBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("mouseOverBrighten");
              // mdBrightenAll (mouseDownBrightenAll)
              //          A button will be lightened by this percentage when the mouse
              //          moves over a button.
              boolean mouseDownBrightenAll = false;
              parm = getParameter("mdBrightenAll");
              if (parm != null && parm.charAt(0) == 't') mouseDownBrightenAll = true;
              // mouseDownBrighten (mouseDownBrightenPct)
              //          A button will be lightened by this percentage when it is
              //          clicked.
              int mouseDownBrightenPct = 0;
              try {
                   parm = getParameter("mouseDownBrighten");
                   if (parm != null) mouseDownBrightenPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("mouseDownBrighten");
              // baseBrightenTint (mouseOverBrightenTint)
              // moBrightenTint (mouseOverBrightenTint)
              // mdBrightenTint (mouseDownBrightenTint)
              Color baseBrightenTint = null;
              Color mouseOverBrightenTint = null;
              Color mouseDownBrightenTint = null;
              try {
                   parm = getParameter("baseBrightenTint");
                   if (parm != null) baseBrightenTint = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("moBrightenTint");
                   if (parm != null) mouseOverBrightenTint = new Color(Integer.parseInt(parm, 16));
                   parm = getParameter("mdBrightenTint");
                   if (parm != null) mouseDownBrightenTint = new Color(Integer.parseInt(parm, 16));
              catch (Exception e) {
                   reportError("baseBrightenTint, moBrightenTint or mdBrightenTint");
              // buttonsDisabledDim (buttonsDisabledDimPct)
              //          If a button is disabled and if there is no buttonsDisabled image,
              //          then the button will be dimmed by this percentage.
              int buttonsDisabledDimPct = 25;
              try {
                   parm = getParameter("buttonsDisabledDim");
                   if (parm != null) buttonsDisabledDimPct = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("buttonsDisabledDim");
              // grayBarBrighten
              //          If there is no mouseOver image, then the base image will be used for
              //          the mouseOver image, and a grayscale version of the base image will
              //          be used for base button images. This parameter can be used to lighten
              //          COLORS (not grays) in the image before it is converted to grayscale.
              //          This can help if the standard conversion produces buttons that are
              //          too dark.
              int grayBarBrighten = 0;
              try {
                   parm = getParameter("grayBarBrighten");
                   if (parm != null) grayBarBrighten = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("grayBarBrighten");
              // frameRate
              //          If a mouseOver2 image is specified, then this parameter controls
              //          how quickly animation will be performed (using mouseOver and mouseOver2
              //          images) in milliseconds when the mouse is moved over a button.
              int frameRate = 150;
              try {
                   parm = getParameter("frameRate");
                   if (parm != null) frameRate = Integer.parseInt(parm);
              catch (Exception e) {
                   reportError("frameRate");
              // =================================================================
              // Instantiate the button bar
              // =================================================================
              try {
                   // Allow the use of documentBase (default) or codeBase for image file
                   // base directory.
                   URL documentBase;
                   parm = getParameter("useCodeBase");
                   if (parm == null || parm.equals("false")) documentBase = getDocumentBase();
                   else documentBase = getCodeBase();
                   // Create the button bar
                   buttonBar = new ButtonBar(
                                                 horizontal,                         /* barHorizontal */
                                                 documentBase,                         /* base */
                                                 baseBar,                              /* baseBarName */
                                                 getParameter("mouseOver"),     /* mouseOverBarName */
                                                 getParameter("mouseOver2"),     /* mouseOverBar2Name */
                                                 getParameter("mouseDown"),     /* mouseDownBarName */
                                                 getParameter("mouseDownOver"), /* mouseDownOverBarName */
                                                 getParameter("buttonsDisabled"),/* buttonsDisabledBarName */
                                                 getParameter("background"),     /* backgroundImageName */
                                                 barXPos,                              /* barXBackgroundPos */
                                                 barYPos,                              /* barYBackgroundPos */
                                                 drawButtonBorders,               /* drawButtonBorders */
                                                 borderColorTopLeft,               /* borderColorTopLeft */
                                                 borderColorBottomRight,          /* borderColorBottomRight */
                                                 borderIntensityPercent,          /* borderIntensityPercent */
                                                 buttonBorderSize,                    /* buttonBorderSize */
                                                 downShift,                         /* downShift */
                                                 downShiftAmt,                         /* downShiftAmt */
                                                 baseBrightenPct,                    /* baseBrightenPct */
                                                 baseBrightenTint,                    /* baseBrightenTint */
                                                 mouseOverBrightenPct,               /* mouseOverBrightenPct */
                                                 mouseOverBrightenTint,          /* mouseOverBrightenTint */
                                                 mouseDownBrightenAll,               /* mouseDownBrightenAll */
                                                 mouseDownBrightenPct,               /* mouseDownBrightenPct */
                                                 mouseDownBrightenTint,          /* mouseDownBrightenTint */
                                                 buttonsDisabledDimPct,          /* buttonsDisabledDimPct */
                                                 grayBarBrighten,                    /* grayBarBrighten */
                                                 frameRate                              /* frameRate */     
                   // =================================================================
                   // Add buttons to the button bar
                   // =================================================================
                   ButtonRegion buttonToAdd;
                   String buttonNbr, urlString;
                   URL urlForButton;
                   int nbr = 0;
                   int buttonStart, buttonSize;
                   // Initialize button on bar flag (used to determine if at least one button
                   // was successfully added to the button bar)
                   boolean buttonOnBar = false;
                   // This loop will be exited when no more buttons can be found in the HTML
                   while (true) {
                        // Construct the prefix for the button parameters
                        buttonNbr = "button" + ++nbr;
                        // Find the starting offset and the size of the button
                        // If null is returned as the starting offset parameter value for the
                        // button, then all buttons should have been read so the loop can
                        // be exited.
                        try {
                             parm = getParameter(buttonNbr + "Start");
                             if (parm == null) break;
                             buttonStart = Integer.parseInt(parm);
                             buttonSize = Integer.parseInt(getParameter(buttonNbr + "Size"));
                        catch (Exception e) {
                             reportError("Button" + nbr + " start or size in error or missing");
                             buttonStart = 0;
                             buttonSize = 0;
                        // Create a ButtonRegion for the button
                        // The button ID will be set to the number of the button (this will
                        // be converted to an integer later when a buttonBarEvent is received).
                        buttonToAdd = new ButtonRegion("" + nbr, buttonStart, buttonSize);
                        // If the buttons on this button bar are "sticky" buttons, then
                        // enable "sticky" behavior for this button. The button will always
                        // "pop-up" whenever another button is clicked.
                        if (stickyBar >= 0) {
                             buttonToAdd.stickyButton(true, ButtonRegion.POPUP_ALWAYS, false);
                             // If the current button number matches the value of stickyBar, then the
                             // current button should be "stuck" down for its initial state.
                             if (stickyBar == nbr) buttonToAdd.setStuck(true);
                        // Try to add the button (i.e., the ButtonRegion) to the buttonBar
                        if (buttonBar.addButton(buttonToAdd)) {
                             // Set flag to indicate that at least one button has been added
                             buttonOnBar = true;
                             // The button was successfully added, so save the button's description
                             // (which will be displayed in the status bar) and the target frame
                             // for the button URL in the appropriate Vector.
                             buttonDescription.addElement(getParameter(buttonNbr + "Desc"));
                             buttonURLTarget.addElement(getParameter(buttonNbr + "Target"));
                             // Try to create a URL for the button.
                             // If the URL is invalid, then place an error message in the
                             // buttonURLTarget Vector (this will be used to warn the user
                             // when the button is clicked). Also, if disableBadURL is true, then
                             // disable the button.
                             String theURL;
                             urlString = getParameter(buttonNbr + "URL");
                             if (urlString != null) {
                                  Enumeration urls = new StringTokenizer(urlString);
                                  while (urls.hasMoreElements()) {
                                       theURL = (String)urls.nextElement();
                                       try {
                                            urlForButton = new URL(theURL);
                                       catch (Exception e) {
                                            try {
                                                 urlForButton = new URL(getDocumentBase(), theURL);
                                            catch (Exception e2) {
                                                 reportError("Button" + nbr + " has invalid URL");
                                                 buttonURLTarget.setElementAt("Invalid URL", nbr - 1);
                                                 urlString = null;
                                                 break;
                             else {
                                  reportError("Button" + nbr + " has no URL");
                                  buttonURLTarget.setElementAt("No URL", nbr - 1);
                             buttonURL.addElement(urlString);
                   // Remove any unused elements in the Vectors
                   buttonURL.trimToSize();
                   buttonURLTarget.trimToSize();
                   buttonDescription.trimToSize();
                   // If no buttons were added, throw exception
                   if (!buttonOnBar) throw new IllegalArgumentException("No buttons on bar");
                   // Let the buttonBar know that all buttons have been defined. This is
                   // really only necessary if downShift is true, but it won't hurt calling
                   // the method in either case.
                   buttonBar.allButtonsDefined();
                   // Add the applet as an observer so that the applet will be notified
                   // when button events occur.
                   buttonBar.addButtonObserver(this);
                   // Enable the button bar now that all buttons have been defined.
                   // (the buttonBar is disabled when it is created and must be
                   // specifically enabled).
                   buttonBar.enable(true);
                   // Add the buttonBar to the applet
                   setLayout(null);
                   add(buttonBar);
              catch (Exception e) {
                   reportError("Can't create ButtonBar\n" + e);
         // buttonBarEvent
         //          This method is called by the ButtonBar whenever a button event occurs
         //          It provides the ButtonBar that the event occurred for, the button ID
         //          that the event occurred for, and the event type.
         public void buttonBarEvent(ButtonBar barID, String buttonID, int buttonEvent) {
              String description;
              // The buttonBar will send an IMAGES_READY event when all button bar images
              // have been prepared. We are not interested in this event, but only in
              // certain "action" events that occur for a button.
              if (buttonEvent != ButtonBar.IMAGES_READY) {
                   // A number in String format was assigned as the buttonID when each
                   // ButtonRegion was created. The buttonID String will now be converted
                   // back into a number that can be used as a Vector index to retrieve
                   // button specific information (i.e., URL, target frame, and description).
                   int buttonNbr = Integer.parseInt(buttonID) - 1;
                   switch (buttonEvent) {
                        // If a mouseDown event has occurred for the button, and if an
                        // AudioClip is available for this event, play the AudioClip.
                        case ButtonBar.MOUSE_CLICK:     
                             if (mouseClickAudio != null) mouseClickAudio.play();
                             break;
                        // If the mouse has been moved over a button, display the button's
                        // description in the browser's status area. If the button that the mouse
                        // is over is an active button, and if there is an AudioClip available
                        // for this event, then play the audio clip.
                        case ButtonBar.MOUSE_ENTER:     
                        case ButtonBar.MOUSE_ENTER_DISABLED:
                             description = (String)buttonDescription.elementAt(buttonNbr);
                             if (description != null) showStatus(description);
                             if (mouseEnterAudio != null && buttonEvent == ButtonBar.MOUSE_ENTER) {
                                  mouseEnterAudio.play();
                             break;
                        // If the mouse has been moved off of a button and if the button has
                        // description text associated with it, then clear the browser's
                        // browser's status area.
                        case ButtonBar.MOUSE_EXIT:
                        case ButtonBar.MOUSE_EXIT_DISABLED:
                             description = (String)buttonDescription.elementAt(buttonNbr);
                             if (description != null) showStatus("");
                             break;
                        // If the button has been depressed (i.e., a mouseDown followed by
                        // a mouseUp for the same button) then load the URL(s) for the button
                        // in the target frame(s), if specified. If the URL is null, then the
                        // URL was found to be missing or invalid, so display the text stored in
                        // the buttonURLTarget Vector in the brower's status area. If there is
                        // an AudioClip for the event, play the audio.
                        case ButtonBar.BUTTON_DOWN:
                             // Get the string of URLs and Targets for the button
                             String urlString = (String)buttonURL.elementAt(buttonNbr);
                             String targetString = (String)buttonURLTarget.elementAt(buttonNbr);
                             // If there is at least one URL for the button
                             if (urlString != null) {
                                  URL urlForButton;
                                  String theURL;
                                  String theTarget;
                                  Enumeration urls = new StringTokenizer(urlString);
                                  Enumeration targets = null;
                                  if (targetString != null) targets = new StringTokenizer(targetString);
                                  // While there is another URL for the button
                                  while (urls.hasMoreElements()) {
                                       // Get the next String token that represents a URL
                                       theURL = (String)urls.nextElement();
                                       // Convert the String to a URL
                                       try {
                                            urlForButton = new URL(theURL);
                                       catch (Exception e) {
                                            try {
                                                 urlForButton = new URL(getDocumentBase(), theURL);
                                            catch (Exception e2) {
                                                 urlForButton = null;
                                                 break;
                                       // If the String was successfully convert to a URL
                                       if (urlForButton != null) {
                                            // If there is a target for this URL
                                            if (targets != null && targets.hasMoreElements()) {
                                                 // Get the String that represents the target
                                                 theTarget = (String)targets.nextElement();
                                                 // If the target String does NOT begin with a "-",
                                                 // then load the URL in the target
                                                 if (theTarget.charAt(0) != '-') {
                                                      getAppletContext().showDocument(urlForButton, theTarget);
                                                 // Else a target for this URL should not be used
                                                 else {
                                                      getAppletContext().showDocument(urlForButton);
                                            // Else there is no target for this URL, so just show
                                            // the URL.
                                            else {
                                                 getAppletContext().showDocument(urlForButton);
                             // Else URL is missing or invalid
                             else showStatus((String)buttonURLTarget.elementAt(buttonNbr));
                             if (buttonDownAudio != null) buttonDownAudio.play();
                             break;
         // Error reporting
         private void reportError(String message) {
              message = "[ImageURLButtonBar] Error - " + message;
              System.out.println(message);
              showStatus(message);
    }

  • How do I convert an applet to a standalone application.

    Hi Everyone,
    I am currently working on this Applet, I have tried putting the main in and building a frame to hold the applet but everytime I try something I just get new errors, What I conclusively want to do is put the applet in a frame and add menus to the frame. I have listed the code below, its quite a lot, I hope someone can help though, am pulling hair out.
    Many Thanks. Chris
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
      public class SciCalc extends Applet implements ActionListener
      // Entered a UID due to String conversion
        private static final long serialVersionUID = 1;
           int Counter;           //Counts the number of digits entered
           double Result;           //The answer displayed, as well as the second
                                 //operator taken for an operation
           double Operand;          //The first number entered for an operation
           double Mem;            //The variable which holds whatever value the user
                                 //wants kept in "memory"
           boolean DecimalFlag;       //The 'flag' that will signify whether or not the
                                 //decimal button has been pressed
           boolean SignFlag;        //The 'flag' that will signify whether or not the
                                 //plus/minus button has been pressed
           boolean OperatorKey;       //The 'flag' that will signify whether or not any
                                 //operator button has been pressed
           boolean FunctionKey;       //The 'flag' that will signify whether or not any
                        //function button has been pressed
           boolean Rad,Grad,Deg;     //The 'flags' that will signify that Rad, Grad or
                        //deg has been pressed
           int Operator;          //an integer value to indicate which operator
                                 //button was pressed
         char currchar;           //a character to hold the value of the key most
                                 //recently pressed
           String GrStatus;         //String to hold the status of various graphic
                                 //operations of the program
           String Status;           //String to hold the status of various parts
                                 //of the program
    //     LABEL DECLARATIONS 
         //This label will display all error messages
           Label DisplError = new Label(" ",Label.CENTER);
           //This label is just to the left of the Display Label lcdDisplay, and will
           //indicate whether or not a value is being held in the calculator's "memory"
           Label LabelMem = new Label(" ",Label.LEFT);
           Label LabelRad = new Label(" ",Label.CENTER);
           Label LabelDeg = new Label(" ",Label.CENTER);
           Label LabelGrad = new Label(" ",Label.CENTER);
         //This is the Display Label, which is declared as a label so the user will not
            //be able to enter any text into it to possibly crash the calculator
           Label lcdDisplay = new Label("0",Label.RIGHT);
           Label SciCalc = new Label ("Sci Calc V1.0",Label.CENTER);
    //      END OF LABEL DECLARATIONS 
    public void surround (Graphics g){
        g.setColor(new Color(0,0,0));
        g.drawRect(0,0,350,400);
    //      DELCLARATION OF NUMERIC BUTTONS
           Button button1 = new Button("1");
           Button button2 = new Button("2");
           Button button3 = new Button("3");
           Button button4 = new Button("4");
           Button button5 = new Button("5");
           Button button6 = new Button("6");
           Button button7 = new Button("7");
           Button button8 = new Button("8");
           Button button9 = new Button("9");
           Button button0 = new Button("0");
    //      END OF NUMERIC BUTTON DECLARATION
    //     DECLARATION OF OPERATOR BUTTONS
           Button buttonMinus      = new Button("-");
           Button buttonMultiply   = new Button("x");
           Button buttonPlus       = new Button("+");
           Button buttonEquals     = new Button("=");
           Button buttonDivide     = new Button("�");
           Button buttonClear      = new Button("C");
           Button buttonDecimal    = new Button(".");
           Button buttonMPlus      = new Button("M+");
           Button buttonMClear     = new Button("MC");
           Button buttonMRecall       = new Button("MR");
    //     END OF OPERATOR BUTTON DECLARATION 
    //     SCIENTIFIC BUTTON DECLARATION
           Button buttonPi            = new Button("Pi");
           Button buttonSqrt       = new Button("Sqrt");
           Button buttonCbrt       = new Button("Cbrt");
           Button buttonx2            = new Button("x2");
           Button buttonyX         = new Button("yX");
           Button buttonPlusMinus  = new Button("+-");
           Button buttonRad        = new Button("RAD");
           Button buttonGrad       = new Button("GRAD");
           Button buttonDeg        = new Button("DEG");
           Button buttonSin        = new Button("SIN");
           Button buttonCos           = new Button("COS");
           Button buttonTan        = new Button("TAN");
           Button buttonExp        = new Button("EXP");
           Button buttonLogn           = new Button("Ln");
           Button buttonOpenBracket  = new Button("(");
           Button buttonLog        = new Button("log");
    //     END OF SCIENTIFIC BUTTON DECLARATION
    //     START OF INIT METHOD
    //This the only method that is called explicitly -- every other method is
    //called depending on the user's actions.
    public void init()
    //Allows for configuring a layout with the restraints of a grid or
    //something similar
         setLayout(null);
             //APPLET DEFAULTS
        //This will resize the applet to the width and height provided
             resize(350,400);
        //This sets the default font to Helvetica, plain, size 12
                  setFont(new Font("Helvetica", Font.PLAIN, 12));
        //This sets the applet background colour
                       setBackground(new Color(219,240,219));
         //END OF APPLET DEFAULTS
         //LABEL INITIALISATION     
    //Display Panel, which appears at the top of the screen. The label is
    //placed and sized with the setBounds(x,y,width,height) method, and the
    //font, foreground color and background color are all set. Then the
    //label is added to the layout of the applet.
             lcdDisplay.setBounds(42,15,253,30);
             lcdDisplay.setFont(new Font("Helvetica", Font.PLAIN, 14));
             lcdDisplay.setForeground(new Color(0,0,0));
             lcdDisplay.setBackground(new Color(107,128,128));
             add(lcdDisplay);
    //Memory Panel, which appears just to the right of the Display Panel.
    //The label is placed and sized with the setBounds(x,y,width,height)
    //method, and the font, foreground color and background color are all
    //set. Then the label is added to the layout of the applet.
             LabelMem.setBounds(20,15,20,30);
             LabelMem.setFont(new Font("Helvetica", Font.BOLD, 16));
             LabelMem.setForeground(new Color(193,0,0));
             LabelMem.setBackground(new Color(0,0,0));
             add(LabelMem);
    //Rad,Grad and Deg panels,which appear below the memory panel.
             LabelRad.setBounds(20,50,20,15);
             LabelRad.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelRad.setForeground(new Color(193,0,0));
             LabelRad.setBackground(new Color(0,0,0));
             add(LabelRad);
             LabelDeg.setBounds(20,70,20,15);
             LabelDeg.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelDeg.setForeground(new Color(193,0,0));
             LabelDeg.setBackground(new Color(0,0,0));
             add(LabelDeg);
             LabelGrad.setBounds(20,90,20,15);
             LabelGrad.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelGrad.setForeground(new Color(193,0,0));
             LabelGrad.setBackground(new Color(0,0,0));
             add(LabelGrad);
    //SciCalc v1.0 Label, this merely indicates the name.        
             SciCalc.setBounds(60,350,200,50);
             SciCalc.setFont(new Font("papyrus", Font.BOLD, 25));
             SciCalc.setForeground(new Color(0,50,191));
             SciCalc.setBackground(new Color(219,219,219));
             add(SciCalc);
         //END OF LABEL INITIALISATION
         //NUMERIC BUTTON INITIALISATION
             button1.addActionListener(this);
             button1.setBounds(42,105,60,34);
             button1.setForeground(new Color(0,0,0));
             button1.setBackground(new Color(128,128,128));
             button1.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button1);
             button2.addActionListener(this);
             button2.setBounds(106,105,60,34);
             button2.setForeground(new Color(0,0,0));
             button2.setBackground(new Color(128,128,128));
             button2.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button2);
             button3.addActionListener(this);
             button3.setBounds(170,105,60,34);
             button3.setForeground(new Color(0,0,0));
             button3.setBackground(new Color(128,128,128));
             button3.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button3);
             button4.addActionListener(this);
             button4.setBounds(42,145,60,34);
             button4.setForeground(new Color(0,0,0));
             button4.setBackground(new Color(128,128,128));
             button4.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button4);
             button5.addActionListener(this);
             button5.setBounds(106,145,60,34);
             button5.setForeground(new Color(0,0,0));
             button5.setBackground(new Color(128,128,128));
             button5.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button5);
             button6.addActionListener(this);
             button6.setBounds(170,145,60,34);
             button6.setForeground(new Color(0,0,0));
             button6.setBackground(new Color(128,128,128));
             button6.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button6);
             button7.addActionListener(this);
             button7.setBounds(42,185,60,34);
             button7.setForeground(new Color(0,0,0));
             button7.setBackground(new Color(128,128,128));
             button7.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button7);
             button8.addActionListener(this);
             button8.setBounds(106,185,60,34);
             button8.setForeground(new Color(0,0,0));
             button8.setBackground(new Color(128,128,128));
             button8.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button8);
             button9.addActionListener(this);
             button9.setBounds(170,185,60,34);
             button9.setForeground(new Color(0,0,0));
             button9.setBackground(new Color(128,128,128));
             button9.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button9);
             button0.addActionListener(this);
             button0.setBounds(106,225,60,34);
             button0.setForeground(new Color(0,0,0));
             button0.setBackground(new Color(128,128,128));
             button0.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button0);
         //END OF NUMERIC BUTTON INITIALISATION        
         //OPERATOR BUTTON INITIALISATION         
             buttonDecimal.addActionListener(this);
             buttonDecimal.setBounds(42,225,60,34);
             buttonDecimal.setForeground(new Color(0,0,0));
             buttonDecimal.setBackground(new Color(254,204,82));
             buttonDecimal.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonDecimal);
             buttonPlusMinus.addActionListener(this);
             buttonPlusMinus.setBounds(106,325,60,17);
             buttonPlusMinus.setForeground(new Color(0,0,0));
             buttonPlusMinus.setBackground(new Color(0,118,191));
             buttonPlusMinus.setFont(new Font("Dialog", Font.BOLD, 16));
             add(buttonPlusMinus);
             buttonMinus.addActionListener(this);
             buttonMinus.setBounds(234,145,60,34);
             buttonMinus.setForeground(new Color(0,0,0));
             buttonMinus.setBackground(new Color(254,204,82));
             buttonMinus.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMinus);
             buttonMultiply.addActionListener(this);
             buttonMultiply.setBounds(234,225,60,34);
             buttonMultiply.setForeground(new Color(0,0,0));
             buttonMultiply.setBackground(new Color(254,204,82));
             buttonMultiply.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMultiply);
             buttonPlus.addActionListener(this);
             buttonPlus.setBounds(234,105,60,34);
             buttonPlus.setForeground(new Color(0,0,0));
             buttonPlus.setBackground(new Color(254,204,82));
             buttonPlus.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonPlus);
             buttonEquals.addActionListener(this);
             buttonEquals.setBounds(170,225,60,34);
             buttonEquals.setForeground(new Color(0,0,0));
             buttonEquals.setBackground(new Color(254,204,82));
             buttonEquals.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonEquals);
             buttonDivide.addActionListener(this);
             buttonDivide.setBounds(234,185,60,34);
             buttonDivide.setForeground(new Color(0,0,0));
             buttonDivide.setBackground(new Color(254,204,82));
             buttonDivide.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonDivide);
             buttonClear.addActionListener(this);
             buttonClear.setBounds(234,65,60,34);
             buttonClear.setFont(new Font("Dialog", Font.BOLD, 18));
             buttonClear.setForeground(new Color(0,0,0));
             buttonClear.setBackground(new Color(193,0,0));
             add(buttonClear);
             buttonMPlus.addActionListener(this);
             buttonMPlus.setBounds(170,65,60,34);
             buttonMPlus.setFont(new Font("Dialog", Font.BOLD, 18));
             buttonMPlus.setForeground(new Color(0,0,0));
             buttonMPlus.setBackground(new Color(254,204,82));
             add(buttonMPlus);
             buttonMClear.addActionListener(this);
             buttonMClear.setBounds(42,65,60,34);
             buttonMClear.setForeground(new Color(193,0,0));
             buttonMClear.setBackground(new Color(254,204,82));
             buttonMClear.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMClear);
             buttonMRecall.addActionListener(this);
             buttonMRecall.setBounds(106,65,60,34);
             buttonMRecall.setForeground(new Color(0,0,0));
             buttonMRecall.setBackground(new Color(254,204,82));
             buttonMRecall.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMRecall);
         //END OF OPERATOR BUTTON INITIALISATION
         // SCIENTIFIC BUTTONS INITIALISATION   
             buttonPi.addActionListener(this);
             buttonPi.setBounds(42,265,60,17);
             buttonPi.setForeground(new Color(0,0,0));
             buttonPi.setBackground(new Color(0,118,191));
             buttonPi.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonPi);
             buttonSqrt.addActionListener(this);
             buttonSqrt.setBounds(106,265,60,17);
             buttonSqrt.setForeground(new Color(0,0,0));
             buttonSqrt.setBackground(new Color(0,118,191));
             buttonSqrt.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonSqrt);
             buttonCbrt.addActionListener(this);
             buttonCbrt.setBounds(170,265,60,17);
             buttonCbrt.setForeground(new Color(0,0,0));
             buttonCbrt.setBackground(new Color(0,118,191));
             buttonCbrt.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonCbrt);
             buttonyX.addActionListener(this);
             buttonyX.setBounds(42,285,60,17);
             buttonyX.setForeground(new Color(0,0,0));
             buttonyX.setBackground(new Color(0,118,191));
             buttonyX.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonyX);
             buttonx2.addActionListener(this);
             buttonx2.setBounds(234,265,60,17);
             buttonx2.setForeground(new Color(0,0,0));
             buttonx2.setBackground(new Color(0,118,191));
             buttonx2.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonx2);
             buttonRad.addActionListener(this);
             buttonRad.setBounds(170,285,60,17);
             buttonRad.setForeground(new Color(0,0,0));
             buttonRad.setBackground(new Color(0,118,191));
             buttonRad.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonRad);
             buttonGrad.addActionListener(this);
             buttonGrad.setBounds(234,285,60,17);
             buttonGrad.setForeground(new Color(0,0,0));
             buttonGrad.setBackground(new Color(0,118,191));
             buttonGrad.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonGrad);
             buttonDeg.addActionListener(this);
             buttonDeg.setBounds(106,285,60,17);
             buttonDeg.setForeground(new Color(0,0,0));
             buttonDeg.setBackground(new Color(0,118,191));
             buttonDeg.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonDeg);
             buttonSin.addActionListener(this);
             buttonSin.setBounds(42,305,60,17);
             buttonSin.setForeground(new Color(0,0,0));
             buttonSin.setBackground(new Color(0,118,191));
             buttonSin.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonSin);
             buttonCos.addActionListener(this);
             buttonCos.setBounds(106,305,60,17);
             buttonCos.setForeground(new Color(0,0,0));
             buttonCos.setBackground(new Color(0,118,191));
             buttonCos.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonCos);
             buttonTan.addActionListener(this);
             buttonTan.setBounds(170,305,60,17);
             buttonTan.setForeground(new Color(0,0,0));
             buttonTan.setBackground(new Color(0,118,191));
             buttonTan.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonTan);
             buttonExp.addActionListener(this);
             buttonExp.setBounds(234,305,60,17);
             buttonExp.setForeground(new Color(193,0,0));
             buttonExp.setBackground(new Color(0,118,191));
             buttonExp.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonExp);
             buttonLogn.addActionListener(this);
             buttonLogn.setBounds(234,325,60,17);
             buttonLogn.setForeground(new Color(0,0,0));
             buttonLogn.setBackground(new Color(0,118,191));
             buttonLogn.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonLogn);
             buttonOpenBracket.addActionListener(this);
             buttonOpenBracket.setBounds(42,325,60,17);
             buttonOpenBracket.setForeground(new Color(0,0,0));
             buttonOpenBracket.setBackground(new Color(0,118,191));
             buttonOpenBracket.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonOpenBracket);
             buttonLog.addActionListener(this);
             buttonLog.setBounds(170,325,60,17);
             buttonLog.setForeground(new Color(0,0,0));
             buttonLog.setBackground(new Color(0,118,191));
             buttonLog.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonLog);
         //END OF SCIENTIFIC BUTTON INITIALISATION     
         //DISPLERROR INITIALISATION      
             DisplError.setBounds(42,45,253,15);
             DisplError.setFont(new Font("Dialog", Font.BOLD, 8));
             DisplError.setForeground(new Color(16711680));
             DisplError.setBackground(new Color(0));
             add(DisplError);
         //END OF DISPLERROR INITIALISATION
             Clicked_Clear();      //calls the Clicked_Clear method (C button)
         } //END OF INIT METHOD
    //The following integers are declared as final as they will
    //be used for determining which button has been pushed
         public final static int OpMinus=11,
                                     OpMultiply=12,
                                     OpPlus=13,
                                     OpDivide=15,
                                     OpMPlus=19,
                                     OpMClear=20,
                                     OpMR=21,
                                     OpyX=22,
                                     OpExp=23;
    //This method is called whenever anything needs to be displayed
    //in the error message field at the bottom of the calculator,
    //accepting a String as an argument
      void DisplayError(String err_msg)
    //Calls the setText method of the Label DisplError, sending
    //whatever string it received initially
        DisplError.setText(err_msg);
    //This method is called whenever a numeric button (0-9) is pushed.
    public void NumericButton(int i)
         DisplayError(" ");      //Clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //Checks if an operator key has just been pressed, and if it has,
    //then the limit of 20 digits will be reset for the user so that
    //they can enter in up to 20 new numbers
             if (OperatorKey == true)
               Counter = 0;
             Counter = Counter + 1;    //increments the counter
    //This is a condition to see if the number currently displayed is zero OR
    //an operator key other than +, -, *, or / has been pressed.
             if ((Display == "0") || (Status == "FIRST"))
               Display= "";      //Do not display any new info
             if (Counter < 21)     //if more than 20 numbers are entered
    //The number just entered is appended to the string currently displayed
         Display = Display + String.valueOf(i);
             else
    //call the DisplayError method and send it an error message string
         DisplayError("Digit Limit of 20 Digits Reached");
         lcdDisplay.setText(Display);       //sets the text of the lcdDisplay          
                                       //Label
        Status = "VALID";            //sets the Status string to valid
        OperatorKey = false;           //no operator key was pressed
        FunctionKey = false;           //no function key was pressed
    //This method is called whenever an operator button is pressed, and is   
    //sent an integer value representing the button pressed.
           public void OperatorButton(int i)
         DisplayError(" ");      //Clears the error message field
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
             Result = (new Double(lcdDisplay.getText())).doubleValue();
    //If no operator key has been pressed OR a function has been pressed
         if ((OperatorKey == false) || (FunctionKey = true))
         switch (Operator)     //depending on the operation performed
    //if the user pressed the addition button, add the two numbers
    //and put them in double Result
            case OpPlus     : Result = Operand + Result;
                      break;
    //if the user pressed the subtraction button, subtract the two
    //numbers and put them in double Result
         case OpMinus    : Result = Operand - Result;
                      break;
    //if the user pressed the multiplication button, multiply
    //the two numbers and put them in double Result
            case OpMultiply : Result = Result * Operand;
                      break;
    //if the user pressed the yX button, take first number
    //and multiply it to the power of the second number                 
         case OpyX : double temp1=Operand;
                        for (int loop=0; loop<Result-1; loop++){
                              temp1= temp1*Operand;
                        Result=temp1;
                      break;
    //if the user pressed the Exp button -----------------Find out what this does-------------         
         case OpExp :  temp1=10;
                          for(int loop=0; loop<Result-1; loop++)
                          temp1=temp1*10;
                           Result=Result*temp1;
                     break;
    //if the user pressed the division button, check to see if
    //the second number entered is zero to avoid a divide-by-zero
    //exception
            case OpDivide   : if (Result == 0)
                        //set the Status string to indicate an
                        //an error
                        Status = "ERROR";
                        //display the word "ERROR" on the
                        //lcdDisplay label
                        lcdDisplay.setText("ERROR");
                        //call the DisplayError method and
                        //send it a string indicating an error
                        //has occured and of what type
                        DisplayError("ERROR: Division by Zero");
                      else
                        //divide the two numbers and put the
                        //answer in double Result
                   Result = Operand / Result;
    //if after breaking from the switch the Status string is not set
    //to "ERROR"
              if (Status != "ERROR")
            Status = "FIRST";      //set the Status string to "FIRST" to
                                 //indicate that a simple operation was
                                 //not performed
            Operand = Result; //Operand holds the value of Result
            Operator = i;   //the integer value representing the
                            //operation being performed is stored
                            //in the integer Operator
            //The lcdDisplay label has the value of double Result
            //displayed
         lcdDisplay.setText(String.valueOf(Result));
            //The boolean decimal flag is set false, indicating that the
            //decimal button has not been pressed
         DecimalFlag = false;
            //The boolean sign flag is set false, indicating that the sign
            //button has not been pressed
         SignFlag = false;
            //The boolean OperatorKey is set true, indicating that a simple
            //operation has been performed
         OperatorKey = true;
            //The boolean FunctionKey is set false, indicating that a
            //function key has not been pressed
         FunctionKey = false;
            DisplayError(" ");    //Clears the error message field
      }     //end of OperatorButton method
      //This is a method that is called whenever the decimal button is
      //pressed.
      public void DecimalButton()
        DisplayError(" ");    //Clears the error message field
      //Declares a String called Display that will initialize to whatever
      //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
        //if a simple operation was performed successfully
         if (Status == "FIRST")
          Display = "0";    //set Display string to character 0
        //If the decimal button has not already been pressed
         if (!DecimalFlag)
          //appends a decimal to the string Display
          Display = Display + ".";
        else
               //calls the DisplayError method, sending a string
               //indicating that the number already has a decimal
          DisplayError("Number already has a Decimal Point");
             //calls the setText method of the Label lcdDisplay and
              //sends it the string Display
        lcdDisplay.setText(Display);
         DecimalFlag = true;        //the decimal key has been pressed
             Status = "VALID";        //Status string indicates a valid
                               //operation has been performed
        OperatorKey = false;         //no operator key has been pressed
      } //end of the DecimalButton method
      /* This method is called whenever the percent button is pressed
      void Open_Bracket(){
        String Display = "(";
        lcdDisplay.setText(Display);//-----------Change this--------------
    //This method is called first when the calculator is initialized
    //with the init() method, and is called every time the "C" button
    //is pressed
      void Clicked_Clear()
        Counter = 0;        //sets the counter to zero
        Status = "FIRST";   //sets Status to FIRST
        Operand = 0;        //sets Operand to zero
        Result = 0;         //sets Result to zero
        Operator = 0;       //sets Operator integer to zero
        DecimalFlag = false;         //decimal button has not been
                                     //pressed
        SignFlag = false;          //sign button has not been pressed
        OperatorKey = false;         //no operator button has been
                                //pressed
        FunctionKey = false;         //no function button has been
                                //pressed
    //calls the setText method of Label lcdDisplay and sends
    //it the character "0"
        lcdDisplay.setText("0"); 
        DisplayError(" ");           //clears the error message field
    //This method is called whenever the sign button is pressed
         void PlusMinusButton()
        DisplayError(" ");           //clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //if Status is not set to FIRST and the Display string does not
    //hold the value "0"
        if ((Status != "FIRST") || (Display != "0"))
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
          Result = (new Double(lcdDisplay.getText())).doubleValue();
          //sets the double Result to it's negative value
          Result = -Result;
          //call the setText method of Label lcdDisplay and send it the string
          //that represents the value in Result
          lcdDisplay.setText(String.valueOf(Result));
          Status = "VALID";        //sets Status string to VALID
          SignFlag = true;         //the sign button has been pressed
          DecimalFlag = true;        //a decimal has appeared
      } //end of the PlusMinusButton method
    //This method is called whenever the square button is pressed */
         void SqrButton()
        DisplayError(" ");      //clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //if Status is not set to FIRST and the Display string does not
    //hold the value "0"
        if ((Status != "FIRST") || (Display != "0"))
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
          Result = (new Double(lcdDisplay.getText())).doubleValue();
    //multiply the double Result by itself, effectively squaring
    //the number
          Result = Result * Result;
    //call the setText method of Label lcdDisplay and send it the string
    //that represents the value in Result
         lcdDisplay.setText(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &

    Chris,
    Two issues:
    1) Applet has init(), start(), etc. Application has main().
    2) Applet is a container and you can add stuff to it. With application, you need to create your own container.
    What you want to do is code so that you can run either way. In the applet, create a Panel or JPanel and add everything to the panel. Then add the panel to the applet. Get that working as an applet.
    Now add a main(). All it has to do is create a Frame or JFrame, add the panel to the frame and then call init().
    On another subject, your code looks very good, except for the method length getting out of hand. Try breaking init() into pieces in a bunch of methods:
    public void init() {
       doThis();
       doThat();
       doTheOther();
    private void doThis() {
       // maybe a couple dozen lines here
    // etc.

Maybe you are looking for

  • Oracle in .deb or .rpm

    Installer for Oracle extremaly sucks. Do you hear about Oracle in .deb or .rpm format? Why Orace didn't release its product in common package format? null

  • Help needed working with layers and exporting from acrobat3d

    hi, i am repostng this message becaus eihad no success last time, and I am working under a tight deadline for a school project. any help will be tremendously appreciated I received an Acrobat 3d file with a model that was originally created in CATIA

  • UCS Director : Cannot access cloudsense report

          I have created a Group Admin user, when i am logged in under that user. Under Cloudsense Tab. I can only see 3 reports that i can add to my dashboard. There should be more than 3 when logged on as a Administrator. How do my Group Admin user see

  • Quick look in mail can not show some pdfs

    Mostly quick look in native Mail app can view pdf files flawlessly. Until our SAP software create a pdf file which could only be opened using at least Adobe Reader 8 in PC, and quick look never could show those files. i have to use Adobe Reader from

  • Input data format

    Hi: I am using ni5640r. 1. I want to transfer an array of data which is generated by labview from host to fpga by using Invoke method (write), do I need to set up I and Q before I transfer it and which format am I using U32, U16 or I16?  2. In FPGA,