Applet compiles but doesn't work as intended

My program intends to add, subtract, multiply or divide two numbers, whereby, if the user enters 'A' the program adds the two numbers, and 'S' to subtract them etc. The program compiles fine but as I am pretty new to Java I'm finding it hard to find my error. Reagrds in advance.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
public class CharacterCalculation extends Applet implements ActionListener
     Label input1, input2, input3, output;
     TextField ip1, ip2, ip3, op;
     Double num1, number1, num2, number2, calculationa, calculations, calculationm, calculationd;
     String characterentered;
     public void init()
          setSize(280,180);
          input1 = new Label ("Enter first number here:");
          ip1 = new TextField(5);
          add(input1);
          add(ip1);
          ip1.addActionListener(this);
          number1=0.0;
          input2 = new Label ("Enter mathematical operator here:");
          ip2 = new TextField(5);
          add(input2);
          add(ip2);
          input3 = new Label ("Enter second number here:");
          ip3 = new TextField(5);
          add(input3);
          add(ip3);
          ip3.addActionListener(this);
          number2=0.0;
          output = new Label("The answer is:");
          op = new TextField(32);
          add(output);
          add(op);
          op.setEditable(false);
     public void paint (Graphics graf)
          graf.drawString("A = Add S = Subtract D = Divide M = Multiply",20,160);
     public void actionPerformed(ActionEvent ev)
          num1=Double.parseDouble(ip1.getText());
          num2=Double.parseDouble(ip3.getText());
          characterentered=(ip2.getText());
          calculationa=(num1+num2);
          calculations=(num1-num2);
          calculationm=(num1*num2);
          calculationd=(num1/num2);
          if (characterentered == "A")
               op.setText(Double.toString(calculationa));
          if (characterentered == "S")
               op.setText(Double.toString(calculations));
          if (characterentered == "M")
               op.setText(Double.toString(calculationm));
          if (characterentered == "D")
               op.setText(Double.toString(calculationd));
          else
               op.setText("Please enter a valid mathematical operator");
}

if (characterentered == "A")This is never going to work. A String is an object. What the above line does is compare the reference of characterentered to the reference of the object "A", which will never be the same (they are two different objects stored in two different memory locations).
If you want to compare two strings you need to use the equals() method, so change to four comparison lines to:
if(characterentered.equals("A")){
}

Similar Messages

  • Program compiles but doesn't work

    The folowing program compiles, but it doesn't work, when I type GuessingGame.play(5); into the interactions pane, I get the message
    No 'play' method in 'GuessingGame'. All my brackets line up and I can't see where the problem is. I would definitely apreciate it if you could help!
    /** Allows a user to play a number-guessing game.
    The constructor takes the integer to be guessed. */
    public class GuessingGame {
    int theNumber; //The number to be guessed by the user.
    int guessNumber; //The users guess.
    public void play(int g){
    theNumber=g;
    guessNumber = Integer.parseInt(JOptionPane.showInputDialog("Guess an integer."));
    while(guessNumber!=theNumber){
    if(guessNumber > theNumber){
    JOptionPane.showMessageDialog(null, "Your guess was too high. Guess again.");
    else if(guessNumber < theNumber){
    JOptionPane.showMessageDialog(null, "Your guess was too low. Guess again.");
    JOptionPane.showMessageDialog(null, "You're right!");

    Sorry, it's just that no-one was answering, it took over 2 hours to get a response. I finally got some help now(with the topic as 'Fun to be had by all!'), so you can now just ignore all of them.

  • [iPhone] Calc.app builds fine, but doesn't work as intended

    Hi,
    Trying the Calc example in "Xcode Quick Tour for iPhone OS", I end up with an application that builds and launches fine in the iPhone Simulator, but that doesn't work.
    Did anyone try this example and did it work for you ?
    Here is what I observed :
    When I press a digit, the displayField's value isn't changed.
    Going in debug, I can see that the instance of the Calculator class does receive a message with the "input" selector and with the parameter "character" worth the digit that I pressed. The [_diplay appendString:character], but _display seems to keep being "nil".
    Any idea ?
    Many thanks in advance for your help,
    J.

    The Calc example worked well for me. The only bugginess I found was that if the text field is forced to reduce it's font size it never gets reset to the original size.
    Assuming you didn't touch the Calculator class files it's probably something simple. Check the IB connections, especially the connection between the displayField outlet and the UITextField. Maybe put a NSLog in the press method to check \[_calculator display\]. Of course if your Calculator class files are different from mine all bets are off, so if you don't have any luck we'll need to compare those.

  • My  Applet Jar file doesn't work !!

    hello ,
    I have written this java applet :
    import java.awt.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.URL;
    public class test4 extends Applet implements ActionListener{
         private static final long serialVersionUID = 1L;
         private JButton B1 =new JButton("Forward ");
         private JButton B2 =new JButton("Backward");
         private JButton B3 =new JButton("Left");
         private JButton B4 =new JButton("Right");
    private JPanel P1 = new JPanel();
    private JPanel P2 = new JPanel();
    private JPanel P3 = new JPanel();
    private JPanel P4 = new JPanel();
    private JPanel P5 = new JPanel();
    private JPanel P6 = new JPanel();
    private JLabel L3 = new JLabel(" ");
    private JLabel L4 = new JLabel(" ");
    private JLabel L5 = new JLabel(" ");
    private JLabel L6 = new JLabel(" ");
    private JLabel L7 = new JLabel(" ");
    JSplitPane sppSplitPane0 = new JSplitPane( );
         public test4()
              JFrame.setDefaultLookAndFeelDecorated(true);
              sppSplitPane0.setDividerLocation( 250 );
              P3.add(L4);
              P3.add(B1);
              P3.add(L5);
              P5.add(B3);
              P5.add(L3);
              P5.add(B4);
              P4.add(L6);
              P4.add(B2);
    P4.add(L7);
              P1.setLayout(new BorderLayout());
              P1.add("North",P3);
              P1.add("Center",P5);
              P1.add("South",P4);
              P2.setLayout(new BorderLayout());
              P2.add("North" , P1);
              B1.addActionListener(this);
              B2.addActionListener(this);
              B3.addActionListener(this);
              B4.addActionListener(this);
              sppSplitPane0.setLeftComponent(P2);
              sppSplitPane0.setRightComponent(P6);
         public void actionPerformed(ActionEvent e) {
              try {
                   if (e.getSource() == B4) {
              URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?R");
              System.out.println("URL = " + myNewURL);
              getAppletContext().showDocument(myNewURL,"blank");
                   else
                        if (e.getSource() == B3) {
                        URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?L");
                        System.out.println("URL = " + myNewURL);
                        getAppletContext().showDocument(myNewURL,"blank");
                        else
                             if (e.getSource() == B2) {
                             URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?B");
                             System.out.println("URL = " + myNewURL);
                             getAppletContext().showDocument(myNewURL,"blank");
                             else {
                                  URL myNewURL = new URL("http://amera/cgi-bin/test.cgi?F");
                                  System.out.println("URL = " + myNewURL);
                             getAppletContext().showDocument(myNewURL,"blank");
              } catch (Exception err) {
              System.err.println("Error!\n" + err);
              showStatus("Error, look in Java Console for details!");
         public static void main(String[] args) {
              test t=new test();
              JFrame frame =new JFrame();
              frame.add(t.sppSplitPane0);
              frame.setSize(1100,700);
              frame.setVisible(true);
    i made a jar file :
    i created a file and named it MANIFEST.MF .i wrote inside it :
    Main-Class: test
    Then i placed it in a folder with the test.class .I created jar file using command line.
    I entered the test.class path and then wrote this command :
    jar cvfm myjar.jar MANIFEST.MF *.class
    Then the jar file "myjar.jar" is created .
    it's executed but this function "public void actionPerformed(ActionEvent e) " won't wrok.
    i keep pressing the buttons but nothing is happening !!
    please help me .
    Edited by: Amera on Dec 27, 2009 2:51 PM

    Welcome to the Sun forums.
    Subject: My Applet Jar file doesn't work !! .
    1) Note that one '!' denotes exclamation, whereas 2 or more often denotes a dweeb.
    2) Since you are on your first post, I will point out that applets are an advanced topic, and should not be attempted by newbies.
    3) "doesn't work" is very vague. It is likely to produce a reply like "maybe the applet is lazy - try flogging it".
    Amera wrote:
    ..I have written this java applet :When posting code, code snippets, HTML/XML or input/output, please use the code tags. The code tags help retain the formatting and indentation of the sample. To use the code tags, select the sample and click the CODE button.
    Also note that the most preferred form of code is an SSCCE *(<- link).* In an SSCCE, your would remove all but one button (if the actionPerformed fails with 6 or 7 buttons, trim it down to fail with just one or two.
    i made a jar file :So does the applet work before you make the Jar file? Your post so far suggests the Jar file is the problem.
    i created a file and named it MANIFEST.MF .i wrote inside it :
    Main-Class: test
    Then i placed it in a folder with the test.class .I created jar file using command line.
    I entered the test.class path and then wrote this command :
    jar cvfm myjar.jar MANIFEST.MF *.class
    Then the jar file "myjar.jar" is created .
    it's executed but this function "public void actionPerformed(ActionEvent e) " won't wrok.
    i keep pressing the buttons but nothing is happening !!So you get 'no output in the console & no effect in the applet'?
    What is the URL where I can see your applet failing?
    As an aside, since Sun does not guarantee that applet clients will act on the showDocument command, even if it does not work, it would not be a 'bug'.
    Edited by: AndrewThompson64 on Dec 28, 2009 11:18 AM

  • The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on that  wifi network

    The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on my school wifi. I have an iPhone 4S on AT&T and iOS 7.04

    In a roaming network, your "main" router is the device that would require port mapping/forwarding to be configured in order to access the IP camera from the Internet. This router is also the one that would be provide the private IP address for the camera which you will want to be a static one.
    So as you described your network, the IP cameras should be getting an IP address or you assigned it a static one and this is the address that you would enter in the Private IP address (or equivalent depending on the router used) field when setting up port mapping.
    If you are not able to access this camera from the local network, then this should be troubleshot first.

  • I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I'm having similar issues with my phone.  I got my first iPhone recently, only had an iPod touch gen4 for a little over a year.  Updated to 6.0.2 when we got the phone (iPhone 5) a few days before Christmas.  When I got home on the evening of January 11, my phone would not connect the router anymore.  I was able to get it to connect after resetting the phone and the router, updating the router, and manually connecting.  That laste for a few minutes and then wouldn't work anymore.   I live in an area with very limited service, we have a network extender installed to help, and I am barely getting a 3G signal at times.
    My wife's iPad 4, my touchiPod 4, and all of our laptops are working just fine on the router.  When I dropped my kid off at school today, I noticed that I am not even seeing the school network anymore from the parking lot where before I got 3 or 4 bars and could connect to their wifi when I was there.  Today my phone goes back and forth between seeing my home network but not connecting, to not even seeing the network at all even from the same room that the router is in.
    Hope Apple fixes this problem soon..............

  • HT4314 Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.

    Contact iTunes
    Contact iTunes

  • Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can se

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game. 

    Hello Vaidas Vaidas,
    It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    What is preventing you from changing your password? Any error messages or prompts?
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??

    I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??  Pls help.

    Yup - nothing happens.  I then took the same VGA cable and plugged it into my friend's iPad1 and it worked perfectly when she opened Keynote.  My understanding is that the iPad2 mirrors the entire screen, so no need to go into any specific application in order to project to the screen, right?  Do I need to download any specific app or change any settings in order to be able to project the screen using VGA?
    Sorry - novice at this.  Not very tech minded either...

  • PLSQL compiles but doesn't run.. I've declared it everywhere but still..

    PLSQL compiles but doesn’t run.. I’ve declared it everywhere but still..
    Afternoon.. Hopefully a quick one for someone.. I’m trying to run a Concurrent Program in ORACLE Financials using a Data Template derived BI Publisher report.
    Error message received..
    SUBIXCLT module: UofS Expense Claim Tracking Report
    +--------------------------------------------------------------------------
    All Parameters: raisedby=:status=:claimant=:expense_date_from=:expense_date_to=:LP_ORDERED_BY=Expense Report Number
    Data Template Code: SUBIXCLT
    Data Template Application Short Name: PO
    Debug Flag: N
    {raisedby=, claimant=, expense_date_to=, expense_date_from=, status=, LP_ORDERED_BY=Expense Report Number}
    Calling XDO Data Engine...
    [060410_025628319][][STATEMENT] Start process Data
    [060410_025628324][][STATEMENT] Process Data ...
    [060410_025628329][][STATEMENT] Executing data triggers...
    [060410_025628329][][STATEMENT] BEGIN
    SUBIXCLT.claimant := :claimant ;
    SUBIXCLT.expense_date_from := :expense_date_from ;
    SUBIXCLT.expense_date_to := :expense_date_to ;
    SUBIXCLT.raisedby := :raisedby ;
    SUBIXCLT.status := :status ;
    SUBIXCLT.lp_ordered_by := :lp_ordered_by ;
    :XDO_OUT_PARAMETER := 1;
    END;
    l_flag Boolean;
    BEGIN
    l_flag := SUBIXCLT.BEFOREREPORT(L_ORDERED) ;
    if (l_flag) then
    :XDO_OUT_PARAMETER := 1;
    end if;
    end;
    [060410_025628356][][EXCEPTION] SQLException encounter while executing data trigger....
    java.sql.SQLException: ORA-06550: line 4, column 33:
    PLS-00201: identifier 'L_ORDERED' must be declared
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignoredThe Data Template
    The Data Template
    <?xml version="1.0" encoding="utf-8" ?>
    - <dataTemplate name="UofS_OutstandngExpenses_Report" defaultPackage="SUBIXCLT" dataSourceRef="FINDEV" version="1.0">
    - <properties>
      <property name="xml_tag_case" value="upper" />
      <property name="include_parameters" value="true" />
      <property name="debug_mode" value="on" />
      </properties>
    - <parameters>
      <parameter name="claimant" dataType="character" defaultValue="" />
      <parameter name="expense_date_from" dataType="date" defaultValue="" />
      <parameter name="expense_date_to" dataType="date" defaultValue="" />
      <parameter name="raisedby" dataType="character" defaultValue="" />
      <parameter name="status" dataType="character" defaultValue="" />
      <parameter name="lp_ordered_by" dataType="character" defaultValue="" />
      </parameters>
    - <dataQuery>
      <dataTrigger name="beforeReportTrigger" source="SUBIXCLT.BEFOREREPORT(L_ORDERED)" />
    - <sqlStatement name="Q1">
    - <![CDATA[
    SELECT DISTINCT
    erh.invoice_num,
    pap.full_name EMP_CLAIMING,
    DECODE(NVL(erh.expense_status_code, 'Not yet Submitted (NULL)'), 'CANCELLED', 'CANCELLED',
         'EMPAPPR', 'Pending Individuals Approval',      'ERROR', 'Pending System Administrator Action',
         'HOLD_PENDING_RECEIPTS     ', 'Hold Pending Receipts', 'INPROGRESS', 'In Progress', 'INVOICED', 'Ready for Payment',
         'MGRAPPR', 'Pending Payables Approval', 'MGRPAYAPPR', 'Ready for Invoicing', 'PAID', 'Paid',
         'PARPAID', 'Partially Paid',     'PAYAPPR', 'Payables Approved',     'PENDMGR', 'Pending Manager Approval',
         'PEND_HOLDS_CLEARANCE', 'Pending Payment Verification',     'REJECTED', 'Rejected',     'RESOLUTN',     'Pending Your Resolution',
         'RETURNED',     'Returned',     'SAVED',     'Saved',     'SUBMITTED',     'Submitted',     'UNUSED',     'UNUSED',
         'WITHDRAWN','Withdrawn',     'Not yet Submitted (NULL)') "EXPENSE_STATUS" ,
    NVL(TO_CHAR(erh.report_submitted_date,'dd-MON-yyyy'),'NULL') SUBMIT_DATE,
    NVL(TO_CHAR(erh.expense_last_status_date,'dd-MON-yyyy'),'NULL') LAST_UPDATE,
    erh.override_approver_name ER_Approver,
    fu.description EXP_ADMIN,
    erh.total,
    erh.description 
    FROM
    AP_EXPENSE_REPORT_HEADERS_all erh,
    per_all_people_f pap, fnd_user fu
    WHERE erh.employee_id = pap.person_id
    AND fu.user_id = erh.created_by
    AND NVL(erh.expense_status_code, 'Not yet Submitted') NOT IN  ('MGRAPPR', 'INVOICED', 'PAID', 'PARPAID')
    AND pap.full_name = NVL(:claimant, pap.full_name)
    AND TRUNC(erh.report_submitted_date) BETWEEN NVL(:expense_date_from, '01-JAN-1999') AND NVL(:expense_date_to,'31-DEC-2299')
    AND fu.description = NVL(:raisedby,fu.description)
    AND erh.expense_status_code = NVL(:status,erh.expense_status_code) &LP_ORDERED_BY
      ]]>
      </sqlStatement>
      </dataQuery>
      <dataTrigger name="beforeReportTrigger" source="SUBIXCLT.BEFOREREPORT(L_ORDERED)" />
    - <dataStructure>
    - <group name="G_XP_CLM_TRACKNG" source="Q1">
      <element name="INVOICE_NUM" value="INVOICE_NUM" />
      <element name="EMP_CLAIMING" value="EMP_CLAIMING" />
      <element name="EXPENSE_STATUS" value="EXPENSE_STATUS" />
      <element name="SUBMIT_DATE" value="SUBMIT_DATE" />
      <element name="LAST_UPDATE" value="LAST_UPDATE" />
      <element name="LP_ORDERED_BY" dataType="varchar2" value="SUBIXCLT.LP_ORDERED_BY" />
      </group>
      </dataStructure>
      </dataTemplate>The PL SQL..
    The PL SQL..
    CREATE OR REPLACE PACKAGE Subixclt IS
    L_ORDERED  VARCHAR2(50);
    RAISEDBY VARCHAR2(50);
    STATUS VARCHAR2(50);
    CLAIMANT VARCHAR2(50);
    LP_ORDERED_BY VARCHAR2(50);
    FUNCTION BEFOREREPORT(L_ORDERED IN VARCHAR2) RETURN VARCHAR2;
    EXPENSE_DATE_FROM DATE;
    EXPENSE_DATE_TO DATE;
    --RETURN VARCHAR2;
    END;
    CREATE OR REPLACE PACKAGE BODY Subixclt IS
    FUNCTION BEFOREREPORT(L_ORDERED IN VARCHAR2)RETURN VARCHAR2 IS
    BEGIN
    Fnd_File.PUT_LINE(Fnd_File.LOG,'L_ORDERED'||L_ORDERED);
    DECLARE
    LP_ORDERED_BY VARCHAR2(50);
    L_ORDERED  VARCHAR2(50);
    RAISEDBY VARCHAR2(50);
    STATUS VARCHAR2(50);
    CLAIMANT VARCHAR2(100);
    EXPENSE_DATE_FROM DATE;
    EXPENSE_DATE_TO DATE;
    BEGIN
    IF (LP_ORDERED_BY='Expense Report Number') THEN
         LP_ORDERED_BY :='order by 1 asc;';
      ELSIF (LP_ORDERED_BY='Person Claiming') THEN
         LP_ORDERED_BY :='order by 2 asc;';
      ELSIF (LP_ORDERED_BY='Submit Date') THEN
      LP_ORDERED_BY :='order by 4 asc;';
      END IF;
    RETURN(L_ORDERED);
    --RETURN NULL;
    END;
    END;
    END;Thanks for looking..
    Steven
    Edited by: Mr_Alkan on Jun 4, 2010 3:35 PM

    One has to initialise a session first for use with Oracle Apps if you want to make it run as a concurrent job.
    Any decleration within your package will not be recognised unless initialisation is sucessful.
    Investigate the built-in packages:
    FND_GLOBAL - for initialisation
    FND_SUBMIT - for setting session relevant parameters
    -- function returns true or false depending on whether the initialisation was sucessful or not
    create or replace function is_Init_OK (p_User_Name       in varchar2
                                          ,p_Responsibility  in varchar2
                                          ,p_Language        in varchar2) return boolean as
      b_Set_NLS   boolean;
      b_Set_Mode  boolean;
      r_ISet      fnd_Init := Get_Init_Set(p_User_Name, p_Responsibility);
      begin
        -- 1
        fnd_global.apps_initialize(r_ISet.User_ID, r_ISet.Resp_ID, r_ISet.App_ID);
        -- 2
        b_Set_NLS := fnd_submit.set_nls_options(p_Language);
        -- 3
        b_Set_Mode  := fnd_submit.set_mode (false);
        return (b_Set_Mode and b_Set_NLS and (    (r_ISet.Resp_ID is not null)
                                              and (r_ISet.User_ID is not null)
        exception
          when others then
            return false;
    end is_Init_OK;
    -- for example
    declare
      l_User_ID number = 'IMPORT_POST'; --- import post user
      l_Resp    number =  'Import and Posting responsibility' -- import posting responsibility
      l_Language varchar2(100) := 'AMERICAN';
      b_Init boolean := false;
      INIT_EXCEPTION exception;
    begin
      b_Init := is_Init_OK(l_User_ID, l_Resp, l_Language);
      if (not b_Init) then
        raise INIT_EXCEPTION;
      end if;
      -- conitnue with your processing
      exception 
        when others then
          when INIT_EXECPTION then
          when others then
    end;
    /

  • Applet compiles but does not appear...

    the applet compiles but does not appear :(
    all that appears is a blank box...hopefully someone can help
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class program2 extends Applet implements ActionListener
         private Button btLeft, btRight, btUp, btDown, btBgYellow,
         btBgRed, btBgBlue, btBgOrange, btTxtRed,btTxtYellow, btTxtBlue,
         btTxtOrange, btFtHel, btFtCr, btFtTr, btFtSy;
         private MessagePanel messagePanel;
         private Panel p = new Panel();
         public void init()
              p.setLayout(new BorderLayout());
              messagePanel = new MessagePanel("Java is Life");
              messagePanel.setBackground(Color.white);
              //directional buttons
              Panel pButtons = new Panel();
              pButtons.setLayout(new FlowLayout());
              pButtons.add(btLeft = new Button());
              pButtons.add(btRight = new Button());
              pButtons.add(btUp = new Button());
              pButtons.add(btDown = new Button());
              //Background buttons
              Panel BgButtons = new Panel();
              BgButtons.setLayout(new FlowLayout());
              BgButtons.add(btBgRed = new Button());
              btBgRed.setBackground(Color.red);
              BgButtons.add(btBgYellow = new Button());
              btBgYellow.setBackground(Color.yellow);
              BgButtons.add(btBgBlue = new Button());
              btBgBlue.setBackground(Color.blue);
              BgButtons.add(btBgOrange = new Button());
              btBgOrange.setBackground(Color.orange);
              //text color buttons
              Panel txtButtons = new Panel();
              txtButtons.setLayout(new GridLayout(4,1));
              txtButtons.add(btTxtRed = new Button());
              btTxtRed.setBackground(Color.red);
              txtButtons.add(btTxtYellow = new Button());
              btTxtYellow.setBackground(Color.yellow);
              txtButtons.add(btTxtBlue = new Button());
              btTxtBlue.setBackground(Color.blue);
              txtButtons.add(btTxtOrange = new Button());
              btTxtOrange.setBackground(Color.orange);
              //font buttons
              Panel ftButtons = new Panel();
              ftButtons.setLayout(new GridLayout(4,1));
              ftButtons.add(btFtHel = new Button());
              ftButtons.add(btFtCr = new Button());
              ftButtons.add(btFtTr = new Button());
              ftButtons.add(btFtSy = new Button());
              //layout
              p.add(messagePanel, BorderLayout.CENTER);//set center 1st
              p.add(pButtons, BorderLayout.SOUTH);
              p.add(BgButtons, BorderLayout.NORTH);
              p.add(txtButtons, BorderLayout.EAST);
              p.add(ftButtons, BorderLayout.WEST);
              //listeners
              btLeft.addActionListener(this);
              btRight.addActionListener(this);
              btUp.addActionListener(this);
              btDown.addActionListener(this);
              btBgRed.addActionListener(this);
              btBgYellow.addActionListener(this);
              btBgBlue.addActionListener(this);
              btBgOrange.addActionListener(this);
              btTxtRed.addActionListener(this);
              btTxtYellow.addActionListener(this);
              btTxtBlue.addActionListener(this);
              btTxtOrange.addActionListener(this);
              btFtHel.addActionListener(this);
              btFtCr.addActionListener(this);
              btFtTr.addActionListener(this);
              btFtSy.addActionListener(this);
         //implement listener
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == btLeft)
                   left();
              else if(e.getSource() == btRight)
                   right();
              else if(e.getSource() == btUp)
                   up();
              else if(e.getSource() == btDown)
                   down();
              else if(e.getSource() == btBgRed)
                   red();
              else if(e.getSource() == btBgYellow)
                   yellow();
              else if(e.getSource() == btBgBlue)
                   blue();
              else if(e.getSource() == btBgOrange)
                   orange();
              else if(e.getSource() == btTxtRed)
                   redText();
              else if(e.getSource() == btTxtYellow)
                   yellowText();
              else if(e.getSource() == btTxtBlue)
                   blueText();
              else if(e.getSource() == btTxtOrange)
                   orangeText();
              else if(e.getSource() == btFtHel)
                   helvetica();
              else if(e.getSource() == btFtCr)
                   courier();
              else if(e.getSource() == btFtTr)
                   times();
              else if(e.getSource() == btFtSy)
                   symbol();
         //directional methods :0)
         private void left()
              int x = messagePanel.getXCoordinate();
              if(x > 10)
                   messagePanel.setXCoordinate(x - 10);
                   messagePanel.repaint();
         private void right()
              int x = messagePanel.getXCoordinate();
              if(x < (getSize().width - 5))
                   messagePanel.setXCoordinate(x + 5);
                   messagePanel.repaint();
         private void up()
              int y = messagePanel.getYCoordinate();
              if(y < (getSize().height - 10))
                   messagePanel.setYCoordinate(y - 10);
                   messagePanel.repaint();
         private void down()
              int y = messagePanel.getYCoordinate();
              if(y < (getSize().height + 10))
                   messagePanel.setYCoordinate(y + 10);
                   messagePanel.repaint();
         //background methods :)
         private void red()
              messagePanel.setBackground(Color.red);
         private void yellow()
              messagePanel.setBackground(Color.yellow);
         private void blue()
              messagePanel.setBackground(Color.blue);
         private void orange()
              messagePanel.setBackground(Color.orange);
         //text color methods :)
         private void redText()
              messagePanel.setForeground(Color.red);
         private void yellowText()
              messagePanel.setForeground(Color.yellow);
         private void blueText()
              messagePanel.setForeground(Color.blue);
         private void orangeText()
              messagePanel.setForeground(Color.orange);
         private void helvetica()
              Font myfont = new Font("Helvetica", Font.PLAIN,12);
              messagePanel.setFont(myfont);
         private void courier()
              Font myfont = new Font("Courier", Font.PLAIN,12);
              messagePanel.setFont(myfont);
         private void times()
              Font myfont = new Font("TimesRoman", Font.PLAIN,12);
              messagePanel.setFont(myfont);
         private void symbol()
              Font myfont = new Font("Symbol", Font.PLAIN,12);
              messagePanel.setFont(myfont);

    You add everything to the Panel p but you never add that panel to the applet. What you probably want is to add everything to the applet. An applet is a special kind of panel so you can just change "p" to "this" everywhere in init and remove the declaration of p at the top.

  • After i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    after i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    I already tried that but it doesn't work. Appears a warning saying: "See the developer to make sure that iPhoto works with this version of OS X. You may need to reinstall the application. Be sure to install all available updates in the application and OS X."

  • I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    This article can show you how to disable it through iTunes on a PC/Mac:
    iOS: Configuring accessibility features

  • I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    The easiest way would be to use Back to My Mac, but that will only work if the server is a Mac running OS X 10.7 or later and you have the cooperation of the network administrator.
    OS X: Using and troubleshooting Back to My Mac with your iCloud account

  • Firefox crashing AND the scroll feature on my PC finger pad works with other browsers, but doesn't work on Firefox, which just happened since I updated. FRUSTRATING!

    Since I updated, Firefox is crashing daily. The finger scroll feature on my PC works with other browsers, but doesn't work on Firefox. It is also very, very slow, but other browsers aren't. I can't use it anymore until it's fixed.

    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold (user set).
    *Preferences can be reset to the default via the right-click context menu if they are user set
    *Preferences can be changed via the right-click context menu: Modify (String or Integer) or Toggle (Boolean)
    *http://kb.mozillazine.org/about:config

Maybe you are looking for