ShowStatus problem

hello,
I want to print sum , average , product and maximum and minimum of the 3 numbers. But its showing only the minimum.
why these problem is occuring and how can I get rid of this problem?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Assignment1 extends JApplet
               implements ActionListener
     JLabel integer1,integer2,integer3;
     JTextField input1,input2,input3;
     public void init()
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
          integer1 = new JLabel( "Enter first integer");
          input1 = new JTextField( 10 );
        input1.addActionListener( this);
          integer2 = new JLabel( "Enter second integer");
          input2 = new JTextField( 10 );
        input2.addActionListener( this );
          integer3 = new JLabel( "Enter third integer");
          input3 = new JTextField( 10 );
        input3.addActionListener( this );
          c.add( integer1 );
          c.add( input1 );
          add( integer2 );
          c.add( input2 );
          c.add( integer3 );
          c.add( input3 );
   public void actionPerformed( ActionEvent e )
        int n1 = Integer.parseInt( input1.getText() );
        int n2 = Integer.parseInt( input2.getText() );
        int n3 = Integer.parseInt( input3.getText() );
       showStatus("Sum " + ( n1 + n2 + n3 ) );     //this portion should be changed
       showStatus("Average is " + ( n1 + n2 + n3 ) / 3 ); //
       showStatus("Product is " + ( n1 * n2 * n3 ) );//
       showStatus("Maximum number is " + ( Math.max( n1, Math.max(n2, n3) ) ) );//
       showStatus("Minimum number is " + ( Math.min( n1, Math.min(n2, n3) )  ) );//
}

I want more specificThen say so in the original thread, do not start a new thread.

Similar Messages

  • Replication status ( ttrepadmin -showstatus DSN command ) output problem

    Hi
    I have some question.
    We used 4-way (2-way Active<ttwell01,ttwell02> and 2-way backup<ttwell03,ttwell04> node) replication architecture.
    ttwell01 / ttwell02node of the "stop" was changed Using the following command in ttwell03 node.
    ttwell03 $> ttisql TEST3
    call ttsubscriberstateset('REP1','SCOTT','TEST1','ttwell01',2);
    call ttsubscriberstateset('REP1','SCOTT','TEST2','ttwell02',2);
    Then, through the built-in procedure seems to check the status of the stop.
    ttwell03 $> ttisql TEST3
    Command> columnlabels 1;
    Command> call ttreplicationstatus;
    SUBSCRIBER, HOSTNAME, PORT, PSTATE, LOGS, LASTMSG, REPLICATIONNAME, REPLICATIONOWNER
    < TEST1, ttwell01, 0, stop , 0, 0, REP1 , SCOTT >
    < TEST2, ttwell02, 0, stop , 0, 0, REP1 , SCOTT >
    < TEST4, ttwell04, 0, start , 1, 0, REP1 , SCOTT >
    3 rows found.
    Command> call ttlogholds;
    HOLDLFN, HOLDLFO, TYPE, DESCRIPTION
    < 74937, 3601744, Checkpoint , TEST3.ds0 >
    < 74938, 43305184, Checkpoint , TEST3.ds1 >
    < 74938, 103192920, Replication , ttwell04:TEST4 >
    3 rows found.
    However, "ttrepadmin-showstatus DSN" If you look at the state command to have been started as shown below.
         ttwell03 $> ttrepadmin -showstatus TEST3
         Replication Agent Status as of: 2010-09-06 22:19:09
         DSN : TEST3
         Process ID : 65 (Started)
         Replication Agent Policy : manual
         Host : TTWELL03
         RepListener Port : 48261 (AUTO)
         Last write LSN : 74932.84701216
         Last LSN forced to disk : 74932.82385424
         Replication hold LSN : 74932.82013016
         Replication Peers:
         Name : TEST1
         Host : TTWELL01
         Port : 47007 (AUTO) (Connected)
         Replication State : STARTED <<=======================here
         Communication Protocol : 24
         Name : TEST2
         Host : TTWELL02
         Port : 32848 (AUTO) (Connected)
         Replication State : STOPPED
         Communication Protocol : 24
         Name : TEST4
         Host : TTWELL04
         Port : 46025 (AUTO) (Connected)
         Replication State : STARTED
         Communication Protocol : 24
    TimesTen Replication works properly with the engine and looks as if, ttrepadmin command does not seem right.
    This is a bug?
    Thank you very much.
    GooGyum
    Edited by: user12103686 on 2010. 9. 6 오후 12:00

    Yes, this has been reported before and logged as Bug 9946736: ENHANCE OR CORRECT REPLICATION STATE IN TTREPADMIN -SHOWSTATUS. No fix or enhancement exists for this bug yet.

  • Problem with Listeners/ requestFocus()

    Hello,
    I am new to Java (started learning two months back), There is a problem with the requestFocus() in the focusListener. The program does not return the focus to the object indicated in the requestFocus but it shows multiple cusors!!
    The faculity at the institute where I am learning could not rectify the error.
    Is the error because of the myMethod() which I am using. I had made this method to prove to my professor that we can reduce the code drastically while using the gridbaglayout.
    The code which I had written is as under:
    // file name ShopperApplet.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ShopperApplet extends JApplet implements ActionListener, FocusListener,Runnable
         //static JPanel sP;
         //static JPanel oP;
         JTabbedPane tabbedPane = new JTabbedPane();
         JPanel sP;
         JPanel oP;
         JPanel pwd = new JPanel();
         // Layout Decleration of oP
         GridBagLayout ordL = new GridBagLayout();
         GridBagConstraints ordC = new GridBagConstraints();
         // Layout Decleration of sP
         FlowLayout flow = new FlowLayout();
         // Variables of sP
              JTextField textShopperId;
              JPasswordField textPassword;
              JTextField textFirstName ;
              JTextField textLastName ;
              JTextField textEmailId ;
              JTextField textAddress ;
              JComboBox comboCity ;
              JTextField textState ;
              JTextField textCountryId ;
              JTextField textZipCode ;
              JTextField textPhone ;
              JTextField textCreditCardNo ;
              JRadioButton rbVisa;
              JRadioButton rbMaster;
              JRadioButton rbAmEx;
              ButtonGroup BGccType;
              //JComboBox comboCreditCardType;
              //JTextField textExperyDate;
              JComboBox cmbDt;
              JComboBox cmbMth;
              JComboBox cmbYear;
              JButton btnSubmit;
              JButton btnReset;          
         // Variables of oP
              // Variable Decleration od oP
              JTextField txtOrderNo;
              JTextField txtToyId;
              JTextField txtQty;
              JRadioButton rbYes;     
              JRadioButton rbNo;
              ButtonGroup bgGiftWrap;
              JComboBox cmbWrapperId;
              JTextField txtMsg;
              JTextField txtToyCost;
              JButton btnOSubmit;
              JButton btnOReset;     
         // Variables of pwd
              JTextField txtShopperId;
              JPasswordField txtPassword;
              JButton btnPSubmit;
              JButton btnPReset;     
              JButton btnPNew;
              JButton btnPLogoff;
              JLabel lblN, lblN1;     
              Thread t,t1;
         Font TNR = new Font("Times New Roman",1,15);
         Font arial = new Font("Arial",2,15);
         public void sPDet()
              //Variable Decleration of sP
              textShopperId = new JTextField(6);
              textPassword = new JPasswordField(4);
              textPassword.addFocusListener(this);
              //textPassword = new JTextField(4);
              textPassword.setEchoChar('*');
              textFirstName = new JTextField(20);
              textLastName = new JTextField(20);
              textEmailId = new JTextField(25);
              textAddress = new JTextField(20);
              String cityList[] = {"New Delhi", "Mumbai", "Calcutta", "Hyderabad"};
              comboCity = new JComboBox(cityList);
              comboCity.setEditable(true);
              textState = new JTextField(30);
              textCountryId = new JTextField(25);
              textZipCode = new JTextField(6);
              textPhone = new JTextField(25);
              textCreditCardNo = new JTextField(25);
              String cardTypes[] = {"Visa", "Master Card", "American Express"};
              //comboCreditCardType = new JComboBox(cardTypes);
              rbVisa = new JRadioButton("Visa");
              rbMaster = new JRadioButton("Master Card");
              rbAmEx = new JRadioButton("American Express");
              BGccType = new ButtonGroup();
              BGccType.add(rbVisa);
              BGccType.add(rbMaster);
              BGccType.add(rbAmEx);
              String stDt[] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
              String stMth[] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
              String stYear[] = {"2001","2002","2003","2004","2005","2006","2007","2008","2009","2010"};
              cmbDt = new JComboBox(stDt);
              cmbMth = new JComboBox(stMth);
              cmbYear = new JComboBox(stYear);
              //textExperyDate = new JTextField(10);
              btnSubmit = new JButton("Submit");
              btnReset = new JButton("Reset");
              // Adding Layout Controls
              sP.setLayout(ordL);
              sP.setBackground(Color.green);
              myLayout(textShopperId,3,1,sP,"FM","Shopper Id");
              myLayout(textPassword,3,2,sP,"FM","Password");
              myLayout(textFirstName,3,3,sP,"FM","First Name") ;
              myLayout(textLastName,3,4,sP,"FM","Last Name") ;
              myLayout(textEmailId,3,5,sP,"FM","E-Mail Id") ;
              myLayout(textAddress,3,6,sP,"FM", "Address") ;
              myLayout(comboCity,3,7,sP,"FM","City") ;
              myLayout(textState,3,8,sP,"FM","State") ;
              myLayout(textCountryId,3,9,sP,"FM","Country") ;
              myLayout(textZipCode,3,10,sP,"FM","Zip Code") ;
              myLayout(textPhone,3,11,sP,"FM","Phone") ;
              myLayout(textCreditCardNo,3,12,sP,"FM","Credit Card No.") ;
              //myLayout(rbVisa,3,13,sP);
              JPanel newPanel = new JPanel();
              newPanel.add(rbVisa);
              newPanel.add(rbMaster);
              newPanel.add(rbAmEx);
              myLayout(newPanel,3,13,sP,"FM","Credit Card Type");
              //myLayout(rbMaster,4,13);
              //myLayout(rbAmEx,5,13);
              JPanel newPanel1 = new JPanel();
              newPanel1.add(cmbDt);
              newPanel1.add(cmbMth);
              newPanel1.add(cmbYear);
              myLayout(newPanel1,3,14,sP,"FM","Expiry Date");
              //myLayout(textExperyDate,3,14,sP,"FM");
              myLayout(btnSubmit,1,17,sP,"AL","Submit");
              myLayout(btnReset,3,17,sP,"AL","Reset");          
         public void oPDet()
              txtOrderNo = new JTextField(10);
              txtToyId = new JTextField(10);
              txtQty = new JTextField(10);
              rbYes = new JRadioButton("Yes");
              rbNo = new JRadioButton("No");
              bgGiftWrap = new ButtonGroup();
              bgGiftWrap.add(rbYes);
              bgGiftWrap.add(rbNo);
              String wrapperTypes[] = {"Blue Stripes", "Red Checks", "Green Crosses","Yellow Circles", "Red & Purple Stripes"};
              cmbWrapperId = new JComboBox(wrapperTypes);
              txtMsg = new JTextField(10);
              txtToyCost = new JTextField(10);
              btnOSubmit = new JButton("Submit");
              btnOReset = new JButton("Reset");
              // Adding Controls to oP
              oP.setLayout(ordL);
              oP.setBackground(Color.yellow);
              myLayout(txtOrderNo,3,1,oP,"FM","Order No.");
              myLayout(txtToyId,3,2,oP,"FM","Toy Id");
              myLayout(txtQty,3,3,oP,"FM","Quantity");
              myLayout(rbYes,3,4,oP,"M");
              myLayout(rbNo,4,4,oP,"M");
              myLayout(cmbWrapperId,3,5,oP,"M","Wrapper Id");
              myLayout(txtMsg,3,6,oP,"FM","Message");
              myLayout(txtToyCost,3,7,oP,"FM","Toy Cost");
              myLayout(btnOSubmit,1,8,oP,"AL","Submit");
              myLayout(btnOReset,3,8,oP,"AL","Reset");          
         public void pwdDet()
              pwd.setLayout(ordL);
              pwd.setBackground(Color.green);
              t = new Thread(this);
              t.start();
              t1 = new Thread(this);
              t1.start();
              lblN = new JLabel("");
              lblN1 = new JLabel("");
              txtShopperId = new JTextField(10);
              txtPassword = new JPasswordField(10);
              btnPSubmit = new JButton("Submit") ;
              btnPReset = new JButton("Reset");     
              btnPNew = new JButton("New Member");
              btnPLogoff = new JButton("Log Off");
              pwd.setLayout(ordL);
              pwd.setBackground(Color.yellow);
              myLayout(lblN,3,7,pwd);
              myLayout(lblN1,3,8,pwd);
              myLayout(txtShopperId,3,1,pwd,"FM","Shopper Id.");
              myLayout(txtPassword,3,2,pwd,"FM","Password");
              myLayout(btnPSubmit,2,4,pwd,"AL","Submit");
              myLayout(btnPReset,3,4,pwd,"AL","Reset");          
              myLayout(btnPNew,2,5,pwd,"AL","New");
              myLayout(btnPLogoff,3,5,pwd,"AL","Log Off");
         public void run()
              int ctr =0;
              String ili[] = {"India","is","a","Great","Country"};
              int ctr1 = 0;
              String iib[] = {"India","is","the","Best"};
              Thread myThread = Thread.currentThread();
              if (myThread == t)
                   while (t != null)
                        lblN.setText(ili[ctr]);
                        ctr++;
                        if (ctr >=5) ctr=0;
                        try
                             t.sleep(500);
                        catch(InterruptedException e)
                             showStatus("India is a great Country has been interrupter");
              else
                   while (t1 != null)
                        lblN1.setText(iib[ctr1]);
                        ctr1++;
                        if (ctr1 >=4) ctr1=0;
                        try
                             t1.sleep(1000);
                        catch(InterruptedException e)
                             showStatus("India is the best has been interrupter");
         public void myLayout(JComponent aObj, int x, int y, JPanel aPanel,String aListener,String toolTip)
              ordC.anchor=GridBagConstraints.NORTHWEST;
              JLabel aLabel = new JLabel(toolTip);
              ordC.gridx = x-1;
              ordC.gridy = y;
              ordL.setConstraints(aLabel,ordC);
              aPanel.add(aLabel);
              aObj.setToolTipText("Enter "+toolTip+" here");
              aObj.setForeground(Color.red);
              aObj.setBackground(Color.green);
              if (aListener.indexOf("F")     != -1)
                   aObj.addFocusListener(this);
              //if (aListener.indexOf("M")     != -1)
                   //aObj.addMouseListener(this);
              aObj.setFont(TNR);
              ordC.gridx = x;
              ordC.gridy = y;
              ordL.setConstraints(aObj,ordC);
              aPanel.add(aObj);
         public void myLayout(JComponent aObj, int x, int y, JPanel aPanel,String aListener)
              ordC.anchor=GridBagConstraints.NORTHWEST;
              aObj.setForeground(Color.red);
              aObj.setBackground(Color.green);
              if (aListener.indexOf("F")     != -1)
                   aObj.addFocusListener(this);
              //if (aListener.indexOf("M")     != -1)
                   //aObj.addMouseListener(this);
              aObj.setFont(TNR);
              ordC.gridx = x;
              ordC.gridy = y;
              ordL.setConstraints(aObj,ordC);
              aPanel.add(aObj);
         public void myLayout(JButton aObj, int x, int y, JPanel aPanel,String aListener, String toolTip)
              aObj.setToolTipText(toolTip);
              ordC.anchor=GridBagConstraints.NORTHWEST;
              aObj.setForeground(Color.red);
              if (aListener.indexOf("F")     != -1)
                   aObj.addFocusListener(this);
              //if (aListener.indexOf("M")     != -1)
                   //aObj.addMouseListener(this);
              if (aListener.indexOf("A")     != -1)
                   aObj.addActionListener(this);
              aObj.setFont(TNR);
              ordC.gridx = x;
              ordC.gridy = y;
              ordL.setConstraints(aObj,ordC);
              aPanel.add(aObj);
         public void myLayout(JTextField aObj, int x, int y, JPanel aPanel,String aListener,String toolTip)
              ordC.anchor=GridBagConstraints.NORTHWEST;
              //aObj = new JTextField(10);
              JLabel aLabel = new JLabel(toolTip);
              ordC.gridx = x-1;
              ordC.gridy = y;
              ordL.setConstraints(aLabel,ordC);
              aPanel.add(aLabel);
              aObj.setToolTipText("Enter "+toolTip+" here");
              aObj.setForeground(Color.red);
              if (aListener.indexOf("F")     != -1)
                   aObj.addFocusListener(this);
              //if (aListener.indexOf("M")     != -1)
              //     aObj.addMouseListener(this);
              if (aListener.indexOf("A")     != -1)
                   aObj.addActionListener(this);
              aObj.setFont(TNR);
              ordC.gridx = x;
              ordC.gridy = y;
              ordL.setConstraints(aObj,ordC);
              aPanel.add(aObj);
         public void myLayout(JLabel aObj, int x, int y, JPanel aPanel)
              ordC.anchor=GridBagConstraints.SOUTH;
              aObj.setForeground(Color.blue);
              aObj.setFont(TNR);
              ordC.gridx = x;
              ordC.gridy = y;
              ordL.setConstraints(aObj,ordC);
              aPanel.add(aObj);
         public void init()
              getContentPane().add(tabbedPane);
              sP = new JPanel();
              sPDet();
              oP = new JPanel();
              oPDet();
              pwdDet();
              tabbedPane.addTab("Login",null,pwd,"Login");
              tabbedPane.addTab("Shopper",null,sP,"Shopper Details");
              tabbedPane.addTab("Order",null,oP,"Order Details");
              tabbedPane.setEnabledAt(2, false);
              tabbedPane.setEnabledAt(1, false);
         public void actionPerformed(ActionEvent e)
              Object obj = e.getSource();
              if (obj == btnSubmit)
                   if (validShopperId() == false) return;
                   if (validPassword() == false) return;
                   if (validFirstName() == false) return ;
                   if (validLastName() == false) return ;
                   if (validEmailId() == false) return;
                   if (validAddress() == false) return;
                   if (validState() == false) return;
                   if (validCountryId() == false) return;
                   if (validZipCode() == false) return;
                   if (validCreditCardNo() == false) return ;
                   resetShopper();
                   tabbedPane.setEnabledAt(1,false);
                   tabbedPane.setEnabledAt(2,false);
                   tabbedPane.setSelectedIndex(0);
                   // also can be written as tabbedPane.setSelectedComponent(pwd);
                   //tabbedPane.remove(sP);
              if (obj == btnReset)
                   resetShopper();
                   tabbedPane.setEnabledAt(2,false);
                   //textExperyDate.setText("");
              if (obj == btnOSubmit)
                   if (validOrderNo() == false) return;
                   if (validToyId() == false) return;
                   if (chkNullEntry(txtQty, "Quantity")) return ;
                   if (chkNullEntry(txtToyCost, "Toy Cost")) return ;
              if (obj == btnOReset)
                   resetOrder();
              if (obj == btnPSubmit)
                   if (validPShopperId() && validPPassword())
                        tabbedPane.setEnabledAt(2, true);
                        tabbedPane.setEnabledAt(1, false);
                        txtShopperId.setText("");
                        txtPassword.setText("");
                        resetPassword();
                        //tabbedPane.addTab("Order",null,oP,"Order Details");
              if (obj == btnPReset)
                   resetPassword();
                   tabbedPane.setEnabledAt(1, false);
                   tabbedPane.setEnabledAt(2, false);
              if (obj == btnPNew)
                   tabbedPane.setEnabledAt(1, true);
                   tabbedPane.setEnabledAt(2, false);
                   resetPassword();
                   tabbedPane.setSelectedComponent(sP);
                   //tabbedPane.addTab("Shopper",null,sP,"Shopper Details");          
              if (obj == btnPLogoff)
                   tabbedPane.setEnabledAt(2, false);
                   tabbedPane.setEnabledAt(1, false);
                   resetPassword();
         public void focusGained(FocusEvent fe)
              //Object aObj = fe.getSource();
              //showStatus("Current Object is "+aObj);
         public void resetPassword()
              txtShopperId.setText("");
              txtPassword.setText("");
         public void resetShopper()
                   textShopperId.setText("");
                   textPassword.setText("");
                   textFirstName.setText("") ;
                   textLastName.setText("") ;
                   textEmailId.setText("") ;
                   textAddress.setText("") ;
                   textState.setText("") ;
                   textCountryId.setText("") ;
                   textZipCode.setText("") ;
                   textPhone.setText("") ;
                   textCreditCardNo.setText("") ;
         public void resetOrder()
              txtOrderNo.setText("");
              txtToyId.setText("");
              txtQty.setText("") ;
              txtToyCost.setText("") ;
              txtMsg.setText("") ;
         public void focusLost(FocusEvent fe)
              try{
                   Object obj = fe.getSource();
                   if (obj == textShopperId &&     validShopperId() == false)
                        //textShopperId.requestFocus();
                        return;
                   if (obj == textPassword && validPassword() == false)
                        //textPassword.requestFocus();
                        return;
                   if (obj == textFirstName && validFirstName() == false)
                        //textFirstName.requestFocus();
                        return;
                   if (obj == textEmailId && validEmailId() == false)
                        //textEmailId.requestFocus();
                        return;
                   if (obj == txtOrderNo && validOrderNo() == false)
                        //txtOrderNo.requestFocus();
                        return;
                   if (obj == txtToyId && validToyId() == false);
                        //txtToyId.requestFocus();
                        return;
              catch(Exception e)
                   showStatus("error in LostFocus() Method");
         public boolean validShopperId()
              if (chkNullEntry(textShopperId,"Shopper Id")) return false;
              return true;
         public boolean validPassword()
              if (chkNullEntry(textPassword,"Password")) return false;
              return true;
         public boolean validFirstName()
              if (chkNullEntry(textFirstName,"First Name")) return false;
              return true;
         public boolean validLastName()
              if (chkNullEntry(textLastName,"Last Name")) return false;
              return true;
         public boolean validAddress()
              if (chkNullEntry(textAddress,"Address")) return false;
              return true;
         public boolean validState()
              if (chkNullEntry(textState,"State")) return false;
              return true;
         public boolean validCountryId()
              if (chkNullEntry(textCountryId,"Country")) return false;
              return true;
         public boolean validZipCode()
              if (chkNullEntry(textZipCode,"Postal Code")) return false;
              return true;
         public boolean validCreditCardNo()
              if (chkNullEntry(textCreditCardNo,"Credit Card No.")) return false;
              return true;
         public boolean validEmailId()
              if (chkNullEntry(textEmailId,"Email Address")) return false;
              String s1 = textEmailId.getText();
              int abc = s1.indexOf("@");
              if (abc == -1 || abc == 0 || abc == (s1.length()-1))
                   JOptionPane.showMessageDialog(sP,"Invalid Email Address","Error Message",JOptionPane.ERROR_MESSAGE);
                   //textEmailId.requestFocus();
                   return false;
              return true;
         public boolean validOrderNo()
              if (chkNullEntry(txtOrderNo,"Order No.")) return false;
              return true;
         public boolean validToyId()
              if (chkNullEntry(txtToyId,"Toy Id")) return false;
              return true;
         public boolean chkNullEntry(JTextField aObj,String sDef)
              String s1 = aObj.getText();
              if (s1.length() ==0)
                   try
                        JOptionPane.showMessageDialog(sP,sDef+" cannot be left blank","Error Message",JOptionPane.ERROR_MESSAGE);
                        //showStatus(sDef+" cannot be left blank");
                        // nbvvvv vcz     z111111eeeefgggggggggg aObj.requestFocus();
                   catch(Exception e)
                        showStatus("Error in chkNullEntry() method");
                   return true ;
              else
                   return false;
         public boolean validPShopperId()
              if (chkNullEntry(txtShopperId,"Shopper Id")) return false;
              return true;
         public boolean validPPassword()
              if (chkNullEntry(txtPassword,"Password")) return false;
              return true;
    // end of code.

    Would it not be acceptable to check that each field has a value when Submit is pressed. If a field is found with no data then display the error message and return the focus to the empty field. This would solve the multiple cursors problem as you would not need any focusLost handler code.
    If this is entirely out of the question then you will have to override some of the FocusManager methods to prevent the JVM from handling focus for you :
    FocusManager.setCurrentManager(new DefaultFocusManager() {
      // Override FocusManager methods here.
    });Ronny.

  • Who can help me :)--a problem with java program(reset problem in java )

    I do not know how to make the button reset,my program only could reset diagram but button.If any one who could help me to solve this problem.The problem is When the reset button is pressed, the image should immediately revert to the black square, and the 4 widgets listed above should show values that
    correspond to the black square.The code like this,first one is shapes:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class shapes extends JFrame {
         private JPanel buttonPanel; // panel for buttons
         private DrawPanel myPanel;  // panel for shapes
         private JButton resetButton;
        private JComboBox colorComboBox;
         private JRadioButton circleButton, squareButton;
         private ButtonGroup radioGroup;
         private JCheckBox filledButton;
        private JSlider sizeSlider;
         private boolean isShow;
         private int shape;
         private boolean isFill=true;
        private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
                                   "green", "lightgray", "magenta", "orange",
                                   "pink", "red", "white", "yellow"};   // color names list in ComboBox
        private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
                              Color.gray, Color.green, Color.lightGray, Color.magenta,
                              Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
         public shapes() {
             super("Draw Shapes");
             // creat custom drawing panel
            myPanel = new DrawPanel(); // instantiate a DrawPanel object
            myPanel.setBackground(Color.white);
             // set up resetButton
            // register an event handler for resetButton's ActionEvent
            resetButton = new JButton ("reset");
             resetButton.addActionListener(
              // anonymous inner class to handle resetButton events
                 new ActionListener() {
                       // draw a black filled square shape after clicking resetButton
                     public void actionPerformed (ActionEvent event) {
                             // call DrawPanel method setShowStatus and pass an parameter
                          // to decide if show the shape
                         myPanel.setShowStatus(true);
                             isShow = myPanel.getShowStatus();
                             shape = DrawPanel.SQUARE;
                         // call DrawPanel method setShape to indicate shape to draw
                             myPanel.setShape(shape);
                         // call DrawPanel method setFill to indicate to draw a filled shape
                             myPanel.setFill(true);
                         // call DrawPanel method draw
                             myPanel.draw();
                             myPanel.setFill(true);
                             myPanel.setForeground(Color.black);
                   }// end anonymous inner class
             );// end call to addActionListener
            // set up colorComboBox
            // register event handlers for colorComboBox's ItemEvent
            colorComboBox = new JComboBox(colorNames);
            colorComboBox.setMaximumRowCount(5);
            colorComboBox.addItemListener(
                 // anonymous inner class to handle colorComboBox events
                 new ItemListener() {
                     // select shape's color
                     public void itemStateChanged(ItemEvent event) {
                         if(event.getStateChange() == ItemEvent.SELECTED)
                             // call DrawPanel method setForeground
                             // and pass an element value of colors array
                             myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
                        myPanel.draw();
                }// end anonymous inner class
            ); // end call to addItemListener
            // set up a pair of RadioButtons
            // register an event handler for RadioButtons' ItemEvent
             squareButton = new JRadioButton ("Square", true);
             circleButton = new JRadioButton ("Circle", false);
             radioGroup = new ButtonGroup();
             radioGroup.add(squareButton);
             radioGroup.add(circleButton);
            squareButton.addItemListener(
                // anonymous inner class to handle squareButton events
                new ItemListener() {
                       public void itemStateChanged (ItemEvent event) {
                           if (isShow==true) {
                                 shape = DrawPanel.SQUARE;
                                 myPanel.setShape(shape);
                                 myPanel.draw();
                   }// end anonymous inner class
             );// end call to addItemListener
             circleButton.addItemListener(
                   // anonymous inner class to handle circleButton events
                new ItemListener() {
                       public void itemStateChanged (ItemEvent event) {
                             if (isShow==true) {
                                 shape = DrawPanel.CIRCLE;
                                 myPanel.setShape(shape);
                                 myPanel.draw();
                             else
                                 System.out.println("Please click Reset button first");
                   }// end anonymous inner class
             );// end call to addItemListener
             // set up filledButton
            // register an event handler for filledButton's ItemEvent
            filledButton = new JCheckBox("Filled", true);
             filledButton.addItemListener(
              // anonymous inner class to handle filledButton events
            new ItemListener() {
                  public void itemStateChanged (ItemEvent event) {
                    if (isShow==true) {
                            if (event.getStateChange() == ItemEvent.SELECTED) {
                                  isFill=true;
                                  myPanel.setFill(isFill);
                                  myPanel.draw();
                            else {
                                isFill=false;
                                  myPanel.setFill(isFill);
                                  myPanel.draw();
                    else
                        System.out.println("Please click Reset button first");
              }// end anonymous inner class
             );// end call to addItemListener
            // set up sizeSlider
            // register an event handler for sizeSlider's ChangeEvent
            sizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 300, 100);
            sizeSlider.setMajorTickSpacing(10);
            sizeSlider.setPaintTicks(true);
            sizeSlider.addChangeListener(
                 // anonymous inner class to handle sizeSlider events
                 new ChangeListener() {
                      public void stateChanged(ChangeEvent event) {
                          myPanel.setShapeSize(sizeSlider.getValue());
                             myPanel.draw();
                 }// end anonymous inner class
             );// end call to addChangeListener
            // set up panel containing buttons
             buttonPanel = new JPanel();
            buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
             buttonPanel.add(resetButton);
             buttonPanel.add(filledButton);
            buttonPanel.add(colorComboBox);
            JPanel radioButtonPanel = new JPanel();
            radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
            radioButtonPanel.add(squareButton);
            radioButtonPanel.add(circleButton);
            buttonPanel.add(radioButtonPanel);
            // attach button panel & draw panel to content panel
            Container container = getContentPane();
            container.setLayout(new BorderLayout(10,10));
            container.add(myPanel, BorderLayout.CENTER);
             container.add(buttonPanel, BorderLayout.EAST);
            container.add(sizeSlider, BorderLayout.SOUTH);
            setSize(500, 400);
             setVisible(true);
         public static void main(String args[]) {
             shapes application = new shapes();
             application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }second one is drawpanel:
    import java.awt.*;
    import javax.swing.*;
    public class DrawPanel extends JPanel {
         public final static int CIRCLE = 1, SQUARE = 2;
         private int shape;
         private boolean fill;
         private boolean showStatus;
        private int shapeSize = 100;
        private Color foreground;
         // draw a specified shape
        public void paintComponent (Graphics g){
              super.paintComponent(g);
              // find center
            int x=(getSize().width-shapeSize)/2;
              int y=(getSize().height-shapeSize)/2;
              if (shape == CIRCLE) {
                 if (fill == true){
                     g.setColor(foreground);
                      g.fillOval(x, y, shapeSize, shapeSize);
                else{
                       g.setColor(foreground);
                    g.drawOval(x, y, shapeSize, shapeSize);
              else if (shape == SQUARE){
                 if (fill == true){
                     g.setColor(foreground);
                        g.fillRect(x, y, shapeSize, shapeSize);
                else{
                        g.setColor(foreground);
                    g.drawRect(x, y, shapeSize, shapeSize);
        // set showStatus value
        public void setShowStatus (boolean s) {
              showStatus = s;
         // return showstatus value
        public boolean getShowStatus () {
              return showStatus;
         // set fill value
        public void setFill(boolean isFill) {
              fill = isFill;
         // set shape value
        public void setShape(int shapeToDraw) {
              shape = shapeToDraw;
        // set shapeSize value
        public void setShapeSize(int newShapeSize) {
              shapeSize = newShapeSize;
        // set foreground value
        public void setForeground(Color newColor) {
              foreground = newColor;
         // repaint DrawPanel
        public void draw (){
              if(showStatus == true)
              repaint();
    }If any kind people who can help me.
    many thanks to you!

    4 widgets???
    maybe this is what you mean.
    add this inside your actionPerformed method for the reset action
    squareButton.setSelected(true);
    colorComboBox.setSelectedIndex(0);
    if not be more clear in your post.

  • Code problem

    Hey i've this button on my applet that when clicked passes text entered in a textArea to a seperate class,then shows the result (after the class is finished with it), at least thats what its supposed to do. What happens is that a flock of errors occur. Can anyone spot the problem
    Here's the button code
    public boolean action (Event e, Object o)
         if (e.target == b1)
         first = text1.getText();
         ParseMe parser = new ParseMe(first);
            if( parser.answer()==1){
           showStatus("Answer was" + parser.answer());
           return true;
         }else{
           showStatus("Answer was" + parser.answer());
           return false;
       }and this is the class that the info's bein passed to
    package test.pkg;
    public final class ParseMe {
            //----------------- public interface ---------------------------------------
            public ParseMe(String definition) {
                    // Construct an expression, given its definition as a string.
                    // This will throw an IllegalArgumentException if the string
                    // does not contain a legal expression.
                    parse(definition);
            public double answer(){
              return this.value(1.0,1.0,1.0)+ this.computeStackUsage();
            public double value(double x) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, 0, 0);
            public double value(double x, double y) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, y, 0);
            public double value(double x, double y, double z) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, y, z);
            public String getDefinition() {
                    // Return the original definition string of this expression.  This
                    // is the same string that was provided in the constructor.
                    return definition;
            //------------------- private implementation details ----------------------------------
            private String definition;  // The original definition of the expression,
            // as passed to the constructor.
            private byte[] code;        // A translated version of the expression, containing
            //   stack operations that compute the value of the expression.
            private double[] stack;     // A stack to be used during the evaluation of the expression.
            private double[] constants; // An array containing all the constants found in the expression.
            private static final byte  // values for code array; values >= 0 are indices into constants array
                    PLUS = -1,   MINUS = -2,   TIMES = -3,   DIVIDE = -4,  POWER = -5,
                    UNARYMINUS = -6, VARIABLE_X = -7, VARIABLE_Y = -8, VARIABLE_Z = -9;
            private double eval(double variableX, double variableY, double variableZ) {
          // evaluate this expression for this value of the variable
                    try {
                            int top = 0;
                            for (int i = 0; i < codeSize; i++) {
                                    if (code[i] >= 0)
                                            stack[top++] = constants[code];
    else if (code[i] >= POWER) {
    double y = stack[--top];
    double x = stack[--top];
    double ans = Double.NaN;
    switch (code[i]) {
    case PLUS: ans = x + y; break;
    case MINUS: ans = x - y; break;
    case TIMES: ans = x * y; break;
    case DIVIDE: ans = x / y; break;
    case POWER: ans = Math.pow(x,y); break;
    if (Double.isNaN(ans))
    return ans;
    stack[top++] = ans;
    else if (code[i] == VARIABLE_X) {
    stack[top++] = variableX;
    else if (code[i] == VARIABLE_Y) {
    stack[top++] = variableY;
    else if (code[i] == VARIABLE_Z) {
    stack[top++] = variableZ;
    else {
    double x = stack[--top];
    double ans = Double.NaN;
    switch (code[i]) {
    case UNARYMINUS: ans = -x; break;
    if (Double.isNaN(ans))
    return ans;
    stack[top++] = ans;
    catch (Exception e) {
    return Double.NaN;
    if (Double.isInfinite(stack[0]))
    return Double.NaN;
    else
    return stack[0];
    private int pos = 0, constantCt = 0, codeSize = 0; // data for use during parsing
    private void error(String message) {  // called when an error occurs during parsing
    throw new IllegalArgumentException("Parse error: " + message + " (Position in data = " + pos + ".)");
    private int computeStackUsage() {  // call after code[] is computed
    int s = 0; // stack size after each operation
    int max = 0; // maximum stack size seen
    for (int i = 0; i < codeSize; i++) {
    if (code[i] >= 0 || code[i] == VARIABLE_X
    || code[i] == VARIABLE_Y || code[i] == VARIABLE_Z
    s++;
    if (s > max)
    max = s;
    else if (code[i] >= POWER)
    s--;
    return max;
    private void parse(String definition) {  // Parse the definition and produce all
    // the data that represents the expression
    // internally; can throw IllegalArgumentException
    if (definition == null || definition.trim().equals(""))
    error("No data provided to Expr constructor");
    this.definition = definition;
    code = new byte[definition.length()];
    constants = new double[definition.length()];
    parseExpression();
    skip();
    if (next() != 0)
    error("Extra data found after the end of the expression.");
    int stackSize = computeStackUsage();
    stack = new double[stackSize];
    byte[] c = new byte[codeSize];
    System.arraycopy(code,0,c,0,codeSize);
    code = c;
    double[] A = new double[constantCt];
    System.arraycopy(constants,0,A,0,constantCt);
    constants = A;
    private char next() {  // return next char in data or 0 if data is all used up
    if (pos >= definition.length())
    return 0;
    else
    return definition.charAt(pos);
    private void skip() {  // skip over white space in data
    while(Character.isWhitespace(next()))
    pos++;
    // remaining routines do a standard recursive parse of the expression
    private void parseExpression() {
    boolean neg = false;
    skip();
    if (next() == '+' || next() == '-') {
    neg = (next() == '-');
    pos++;
    skip();
    parseTerm();
    if (neg)
    code[codeSize++] = UNARYMINUS;
    skip();
    while (next() == '+' || next() == '-') {
    char op = next();
    pos++;
    parseTerm();
    if (op == '+')
    code[codeSize++] = PLUS;
    else
    code[codeSize++] = MINUS;
    skip();
    private void parseTerm() {
    parseFactor();
    skip();
    while (next() == '*' || next() == '/') {
    char op = next();
    pos++;
    parseFactor();
    if (op == '*')
    code[codeSize++] = TIMES;
    else
    code[codeSize++] = DIVIDE;
    skip();
    private void parseFactor() {
    parsePrimary();
    skip();
    while (next() == '^') {
    pos++;
    parsePrimary();
    code[codeSize++] = POWER;
    skip();
    private void parsePrimary() {
    skip();
    char ch = next();
    if (ch == 'x' || ch == 'X') {
    pos++;
    code[codeSize++] = VARIABLE_X;
    else if (ch == 'y' || ch == 'Y') {
    pos++;
    code[codeSize++] = VARIABLE_Y;
    else if (ch == 'z' || ch == 'Z') {
    pos++;
    code[codeSize++] = VARIABLE_Z;
    else if (Character.isDigit(ch) || ch == '.')
    parseNumber();
    else if (ch == '(') {
    pos++;
    parseExpression();
    skip();
    if (next() != ')')
    error("Exprected a right parenthesis.");
    pos++;
    else if (ch == ')')
    error("Unmatched right parenthesis.");
    else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '^')
    error("Operator '" + ch + "' found in an unexpected position.");
    else if (ch == 0)
    error("Unexpected end of data in the middle of an expression.");
    else
    error("Illegal character '" + ch + "' found in data.");
    private void parseNumber() {
    String w = "";
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    if (next() == '.') {
    w += next();
    pos++;
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    if (w.equals("."))
    error("Illegal number found, consisting of decimal point only.");
    if (next() == 'E' || next() == 'e') {
    w += next();
    pos++;
    if (next() == '+' || next() == '-') {
    w += next();
    pos++;
    if (! Character.isDigit(next()))
    error("Illegal number found, with no digits in its exponent.");
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    double d = Double.NaN;
    try {
    d = Double.valueOf(w).doubleValue();
    catch (Exception e) {
    if (Double.isNaN(d))
    error("Illegal number '" + w + "' found in data.");
    code[codeSize++] = (byte)constantCt;
    constants[constantCt++] = d;
    /*public static void main(String args[])
    ParseMe me = new ParseMe("1");
    System.out.println(me.value(1,1,1) + ", " + me.computeStackUsage());
    any help would be well appreciated.
    cheers
    podger

    It looks like it parses a mathematical expression represented as a String with up to three variables (x, y, z), and will substitute x, y, and z with whatever values you give it. What is your "text" (value of "first") that you are trying to parse?
    Eventually, you probably want to have text fields for the user to enter x, y, and z, parse those text values as doubles, and pass those to your ParseMe instance by calling: parser.value(x, y, z);
    What happens if you type the following in the text field named "text1"?
    x + y + z

  • A problem with java program(reset problem in java GUY)

    I do not know how to make the button reset,my program only could reset diagram but button.If any one who could help me to solve this problem.The problem is When the reset button is pressed, the image should immediately revert to the black square, and the 4 widgets listed above should show values that
    correspond to the black square.
    import java.awt.*;
    import javax.swing.*;
    public class DrawPanel extends JPanel {
         public final static int CIRCLE = 1, SQUARE = 2;
         private int shape;
         private boolean fill;
         private boolean showStatus;
        private int shapeSize = 100;
        private Color foreground;
         // draw a specified shape
        public void paintComponent (Graphics g){
              super.paintComponent(g);
              // find center
            int x=(getSize().width-shapeSize)/2;
              int y=(getSize().height-shapeSize)/2;
              if (shape == CIRCLE) {
                 if (fill == true){
                     g.setColor(foreground);
                      g.fillOval(x, y, shapeSize, shapeSize);
                else{
                       g.setColor(foreground);
                    g.drawOval(x, y, shapeSize, shapeSize);
              else if (shape == SQUARE){
                 if (fill == true){
                     g.setColor(foreground);
                        g.fillRect(x, y, shapeSize, shapeSize);
                else{
                        g.setColor(foreground);
                    g.drawRect(x, y, shapeSize, shapeSize);
        // set showStatus value
        public void setShowStatus (boolean s) {
              showStatus = s;
         // return showstatus value
        public boolean getShowStatus () {
              return showStatus;
         // set fill value
        public void setFill(boolean isFill) {
              fill = isFill;
         // set shape value
        public void setShape(int shapeToDraw) {
              shape = shapeToDraw;
        // set shapeSize value
        public void setShapeSize(int newShapeSize) {
              shapeSize = newShapeSize;
        // set foreground value
        public void setForeground(Color newColor) {
              foreground = newColor;
         // repaint DrawPanel
        public void draw (){
              if(showStatus == true)
              repaint();
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class shapes extends JFrame {
         private JPanel buttonPanel; // panel for buttons
         private DrawPanel myPanel;  // panel for shapes
         private JButton resetButton;
        private JComboBox colorComboBox;
         private JRadioButton circleButton, squareButton;
         private ButtonGroup radioGroup;
         private JCheckBox filledButton;
        private JSlider sizeSlider;
         private boolean isShow;
         private int shape;
         private boolean isFill=true;
        private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
                                   "green", "lightgray", "magenta", "orange",
                                   "pink", "red", "white", "yellow"};   // color names list in ComboBox
        private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
                              Color.gray, Color.green, Color.lightGray, Color.magenta,
                              Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
         public shapes() {
             super("Draw Shapes");
             // creat custom drawing panel
            myPanel = new DrawPanel(); // instantiate a DrawPanel object
            myPanel.setBackground(Color.white);
             // set up resetButton
            // register an event handler for resetButton's ActionEvent
            resetButton = new JButton ("reset");
             resetButton.addActionListener(
              // anonymous inner class to handle resetButton events
                 new ActionListener() {
                       // draw a black filled square shape after clicking resetButton
                     public void actionPerformed (ActionEvent event) {
                             // call DrawPanel method setShowStatus and pass an parameter
                          // to decide if show the shape
                         myPanel.setShowStatus(true);
                             isShow = myPanel.getShowStatus();
                             shape = DrawPanel.SQUARE;
                         // call DrawPanel method setShape to indicate shape to draw
                             myPanel.setShape(shape);
                         // call DrawPanel method setFill to indicate to draw a filled shape
                             myPanel.setFill(true);
                         // call DrawPanel method draw
                             myPanel.draw();
                             myPanel.setFill(true);
                             myPanel.setForeground(Color.black);
                   }// end anonymous inner class
             );// end call to addActionListener
            // set up colorComboBox
            // register event handlers for colorComboBox's ItemEvent
            colorComboBox = new JComboBox(colorNames);
            colorComboBox.setMaximumRowCount(5);
            colorComboBox.addItemListener(
                 // anonymous inner class to handle colorComboBox events
                 new ItemListener() {
                     // select shape's color
                     public void itemStateChanged(ItemEvent event) {
                         if(event.getStateChange() == ItemEvent.SELECTED)
                             // call DrawPanel method setForeground
                             // and pass an element value of colors array
                             myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
                        myPanel.draw();
                }// end anonymous inner class
            ); // end call to addItemListener
            // set up a pair of RadioButtons
            // register an event handler for RadioButtons' ItemEvent
             squareButton = new JRadioButton ("Square", true);
             circleButton = new JRadioButton ("Circle", false);
             radioGroup = new ButtonGroup();
             radioGroup.add(squareButton);
             radioGroup.add(circleButton);
            squareButton.addItemListener(
                // anonymous inner class to handle squareButton events
                new ItemListener() {
                       public void itemStateChanged (ItemEvent event) {
                           if (isShow==true) {
                                 shape = DrawPanel.SQUARE;
                                 myPanel.setShape(shape);
                                 myPanel.draw();
                   }// end anonymous inner class
             );// end call to addItemListener
             circleButton.addItemListener(
                   // anonymous inner class to handle circleButton events
                new ItemListener() {
                       public void itemStateChanged (ItemEvent event) {
                             if (isShow==true) {
                                 shape = DrawPanel.CIRCLE;
                                 myPanel.setShape(shape);
                                 myPanel.draw();
                             else
                                 System.out.println("Please click Reset button first");
                   }// end anonymous inner class
             );// end call to addItemListener
             // set up filledButton
            // register an event handler for filledButton's ItemEvent
            filledButton = new JCheckBox("Filled", true);
             filledButton.addItemListener(
              // anonymous inner class to handle filledButton events
            new ItemListener() {
                  public void itemStateChanged (ItemEvent event) {
                    if (isShow==true) {
                            if (event.getStateChange() == ItemEvent.SELECTED) {
                                  isFill=true;
                                  myPanel.setFill(isFill);
                                  myPanel.draw();
                            else {
                                isFill=false;
                                  myPanel.setFill(isFill);
                                  myPanel.draw();
                    else
                        System.out.println("Please click Reset button first");
              }// end anonymous inner class
             );// end call to addItemListener
            // set up sizeSlider
            // register an event handler for sizeSlider's ChangeEvent
            sizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 300, 100);
            sizeSlider.setMajorTickSpacing(10);
            sizeSlider.setPaintTicks(true);
            sizeSlider.addChangeListener(
                 // anonymous inner class to handle sizeSlider events
                 new ChangeListener() {
                      public void stateChanged(ChangeEvent event) {
                          myPanel.setShapeSize(sizeSlider.getValue());
                             myPanel.draw();
                 }// end anonymous inner class
             );// end call to addChangeListener
            // set up panel containing buttons
             buttonPanel = new JPanel();
            buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
             buttonPanel.add(resetButton);
             buttonPanel.add(filledButton);
            buttonPanel.add(colorComboBox);
            JPanel radioButtonPanel = new JPanel();
            radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
            radioButtonPanel.add(squareButton);
            radioButtonPanel.add(circleButton);
            buttonPanel.add(radioButtonPanel);
            // attach button panel & draw panel to content panel
            Container container = getContentPane();
            container.setLayout(new BorderLayout(10,10));
            container.add(myPanel, BorderLayout.CENTER);
             container.add(buttonPanel, BorderLayout.EAST);
            container.add(sizeSlider, BorderLayout.SOUTH);
            setSize(500, 400);
             setVisible(true);
         public static void main(String args[]) {
             shapes application = new shapes();
             application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Many thanks

    Who is this Java guy anyway?

  • Solaris 10 x86 64-bit wireless connection problem

    I installed Solaris 10 x86 32-bit on my laptop together with Fedora 10 (Linux) and Windows XP.
    When I boot up Fedora 10 and WinXP, these two OS are able to find the wireless driver automatically, but Solaris 10 failed.
    When I do prtconf -pv, I saw my wireless card is listed in the output.
    So I update the /boot/solaris/devicedb/master and /etc/driver_aliases with my wireless card id - pci168c,001a
    Then do sys-unconfig and reboot
    But after reboot, Solaris still only tries to configure the ethernet card (NIC) rather than checking out the wireless connection.
    I think this might be a design flaw for Solaris 10. If it runs on x86, most users would have wireless connection, not just land line connection.
    Does anyone here have a solution for this problem?
    Thanks a lot!

    I assume that when solaris 10 boots up, it only checks the land line NIC card, not the wireless card. If there is no lan connection, then so be it.
    Is that right?No! :-)
    nwam only supports one device but the device is selectable. physical should activate all devices regardless. So if your Wifi isn't working then I would use wificonfig to see what it can see. Check the man page for scan and showstatus options. Then you'll know what it's seeing.
    alan

  • JSP PROBLEM...THEORETICAL QUESTION

    Hi as you all know by now im quite new to jsp and have struggled so far to get something decent working but now that i have im happy :D
    quick question for you all...
    imagine this scenario. when you submit an application for something...i.e. a job...your application status is 'pending' and when moved to the interview stage the status is changed to 'interview' and then if successful changes to 'job offer'
    these 3 'status' would be done as final int data types in java...ive done it before and thats not a problem. however how is one to approach that using jsp?? can it be done...if so, how??
    also when the user logs in to check the current status of his/her application they should be presented with this status either pending/interivew/job offer.
    any ideas??
    at the moment all i have done is an application submission which gets stored in an access database. i am nowworking on the part which manipulates the submitted applications according to criteria
    thanks!

    Level_ID Level_Name
    0 Pending
    1 Interview
    2 Offer
    3 Rejection
    how would i make a user who logs in to see his status
    as the word pending rather than 0?? i.e. how can i
    point the Level_ID in Login_Details table to find its
    corresponding Level_Name in the Levels table?Create a HashMap at init of your Main Servlet that is populated by this data, keyed by Integer. Make this table reloadable via an HTTP call, that way if you want to update the names you can do so without needing to restart your webserver.
    Then when its time to show the name, rather than the number, do :
    <%= servlet.statusTable.get( new Integer( user.getStatus() ) ) %>
    Probably would be a good idea to put this into a method so you can verify that the object exists, etc., call it showStatus(user)

  • APPLET'S STOP METHOD - PROBLEM!!

    I'm learning java on my own, and I have a problem. Could you help me.
    The stop()** method in my applet does not show on the appletviewer until I close the appletviewer.
    I open another program like notepad, but when I come back to the appletviewer it doesen't show!
    It only shows right before I close it.
    Why is that?
    Thanks
    stop() {
    showStatus("STOPPED");

    Dear JustAnotherProgramer,
    pillaged from the docs
    stop
    public void stop()
    Called by the browser or applet viewer to inform this applet that it should stop its execution. It is called when the Web page that contains this applet has been replaced by another page, and also just before the applet is to be destroyed.
    It seems that if you run it in a browser and you go to the other page(same browser) it will be called.
    I guess by changing focus between different application(notepad) it will not work.
    Thank
    Joey

  • Scheduler problem after 9102 upgrade

    Hi all,
    Would really appreciate some help diagnosing this one:
    After upgrading ffrom 9101 -> 9102 I now have a problem with the scheduler.
    I'm running weblogic and now notice that I have three different versions of xlScheduler.jar in:
    \xellerate\lib
    \xellerate\OIMApplications\WLXellerateFull.ear &
    \xellerate\OIMApplications\WLXellerateFull.ear\xlScheduler.war\WEB-INF\lib
    with sizes of 122, 176 1nd 182k. (Although this was also the case with 9101 so may not be relevant....)
    Scheduling tasks in OIM causes an exception and if I login to the scheduler at http://<server>:7001/xlScheduler/ I get an error and the following log output:
    <11-Mar-2010 10:44:42 o'clock GMT> <Error> <HTTP> <BEA-101020> <[ServletContext@13128904[app:WLXellerateFull module:/xlScheduler path:/xlScheduler spec-version:null]] Servlet failed with Exception
    java.lang.NullPointerException
    at com.thortech.xl.scheduler.deployment.webapp.SchedulerInitServlet.getTaskListView(Unknown Source)
    at com.thortech.xl.scheduler.deployment.webapp.SchedulerInitServlet.showStatus(Unknown Source)
    at com.thortech.xl.scheduler.deployment.webapp.SchedulerInitServlet.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    Truncated. see log file for complete stacktrace
    Thanks,
    Bernie
    Edited by: BernieJ on 11-Mar-2010 03:30

    Hi
    Check sufficient space available in Temp tablespace.
    Venkat

  • 64 bit OBI Connection problem

    Hi all,
    I have a problem with oracle bi-database connection. Currenty when I try to import from ODBC 3.5 datasource what oraclebi shows me does not exist in ODBC connection, and also when I added a new odbc connection to system dsn I cannot see it from Oracle BI. It is like looking to entirely different machine.
    Computer is 64 bit windows. I installed OBISE1, in installation both oracle and obi software were installed succesfully but I had a problem when it was trying to create the sample bise1db database(credential retrieval failed). Then I installed 64 bit oracle software, pachted it to 10.2.0.4 and created the database instance(I received the same error when creating 64 instance but I updated sqlnet.ora and I successfully created instance).
    I restated Oracle BI services but now Oracle BI is behaving like it is not in the same computer I am looking at. It is not possible to import from ODBC 3.5 because it is not seeing System DSN connections. I also tried to create new database and connection pool and manually configure in the physical layer but still I get connection errors.
    Currenty there are two oracle software in the computer, 32bit 10g and 64 bit 10g and only one instance that is created with 64 bit software.
    I am not sure it was a mistake to install OBISE1 software to 64 bit machine.
    Any help would be appreciated..

    I assume that when solaris 10 boots up, it only checks the land line NIC card, not the wireless card. If there is no lan connection, then so be it.
    Is that right?No! :-)
    nwam only supports one device but the device is selectable. physical should activate all devices regardless. So if your Wifi isn't working then I would use wificonfig to see what it can see. Check the man page for scan and showstatus options. Then you'll know what it's seeing.
    alan

  • Problems with display() method

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class lifeCycle extends JApplet implements ActionListener
         JLabel messageInit = new JLabel("init ");
         JLabel messageStart = new JLabel("start ");
         JLabel messageDisplay = new JLabel("display ");
         JLabel messageAction = new JLabel("action ");
         JLabel messageStop = new JLabel("stop ");
         JLabel messageDestroy = new JLabel("destroy ");
         JButton pushButton = new JButton("Hit me!");
         int countInit, countStart, countDisplay, countAction, countStop, countDestroy;
              public void init(){
                  Container con = getContentPane();
                  con.setLayout (new FlowLayout());
                  ++countInit;
                  con.add(messageInit);
                  con.add(messageStart);
                  con.add(messageDisplay);
                  con.add(messageAction);
                  con.add(messageStop);
                  con.add(messageDestroy);
                  con.add(pushButton);
                  pressButton.addActionListener(this);
                  display();
                  showStatus("complete");
              public void start(){
              ++countStart;
              display();
              showStatus("complete");
              public void stop(){
                  ++countStop;
                  display();
                  showStatus("complete");
              public void destroy(){
                  ++countDestroy;
                  display();
                  showStatus("complete");
              public void actionPerformed(ActionEvent e){
                  Object source = e.getSource();
                  if(source == pushButton){
                   ++countAction;
                   display();
                   showStatus("complete");
    }Just trying to learn the basics of life cycles in the swing applet. The display() method is where we're having problems, I'm getting the "cannot resolve symbol" message. I was just wondering what I'm doing wrong here. Thanks!
    Kate

    hi,
    I'm not sure what your applet is suppose to do but i've made some changes. I've moved your Container object declaration out of the "init()", and instead of "pressButton" I changed it to "pushButton" and "display()" to "con.setVisible(true)".
    hope this will resolve your issue. Here is the edited code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class lifeCycle extends JApplet implements ActionListener
         JLabel messageInit = new JLabel("init ");
         JLabel messageStart = new JLabel("start ");
         JLabel messageDisplay = new JLabel("display ");
         JLabel messageAction = new JLabel("action ");
         JLabel messageStop = new JLabel("stop ");
         JLabel messageDestroy = new JLabel("destroy ");
         JButton pushButton = new JButton("Hit me!");
         int countInit, countStart, countDisplay, countAction, countStop, countDestroy;
            Container con = getContentPane(); // Moved from init() to here
              public void init(){             
                  con.setLayout (new FlowLayout());
                  ++countInit;
                  con.add(messageInit);
                  con.add(messageStart);
                  con.add(messageDisplay);
                  con.add(messageAction);
                  con.add(messageStop);
                  con.add(messageDestroy);
                  con.add(pushButton);
                  pushButton.addActionListener(this);
                        // edited from "pressButton" to "pushButton"
                  con.setVisible(true); //used the Container object you created
                                              // instead of "display()";
                  showStatus("complete");
              public void start(){
              ++countStart;
              con.setVisible(true);   //used the Container object you created
                                            // instead of "display()";
              showStatus("complete");
              public void stop(){
                  ++countStop;
                  con.setVisible(true);   //used the Container object you created
                                                // instead of "display()";
                  showStatus("complete");
              public void destroy(){
                  ++countDestroy;
                  con.setVisible(true);  //used the Container object you created
                                                // instead of "display()";
                  showStatus("complete");
              public void actionPerformed(ActionEvent e){
                  Object source = e.getSource();
                  if(source == pushButton){
                   ++countAction;
                   con.setVisible(true);  //used the Container object you created
                                                   // instead of "display()";
                   showStatus("complete");
    }

  • ShowStatus, how do i pass messages around? genius needed...

    I posted this earlier & offered duke dollars on it...
    either no one can help me or no one has seen this...
    so i have repeated the post (sorry).
    I think i need a resident genius on this one!
    Purpose of pgm: to teach kids the mulitplication table. A question appears in the status bar "how much is 7 x 5", kid answers, answer is checked. If answer is correct display in status bar "excellent" else answer is wrong so display "incorrect". If the answer is incorrect display the same question in the status bar.
    my problem: The teachers responses are not appearing in the status bar� how can i fix this? Compounding problem: all questions & responses MUST be displayed in the status bar. (the questions ARE appearing in the status bar).
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.Graphics;
    public class Ex6_31 extends JApplet implements ActionListener{
       int num1, num2;
       JLabel resultLabel;
       JTextField ans;
       String message = "";
       public void init(){
          Container c = getContentPane();
          c.setLayout( new FlowLayout());
          resultLabel = new JLabel( "my answer > " );
          c.add( resultLabel );
          ans = new JTextField( 10 );
          ans.addActionListener( this );
          c.add(ans);
          getMultiplicands();
          poseQuestion();
       }//end of init
       public void actionPerformed( ActionEvent e ){
          int response = Integer.parseInt( ans.getText() );//users response to first question
          int mark = checkAnswer(response);                //mark=1 if correct, 0 if wrong
          teacher(mark);                                   //call the teacher for her response
          while (mark == 0){                                //if the answer was wrong
             ans.setText("");                               //clear the answer textField
             poseQuestion();                                //ask the same question
             response = Integer.parseInt( ans.getText() );  //get the users answer
             mark = checkAnswer(response);                  //check the users answer
             teacher(mark);                                //call the teacher for her response
          ans.setText("");                               //clear the answer textField
          getMultiplicands();                            //create a new question
          poseQuestion();                                //pose question to user
       }//end of actionPerformed
       public void getMultiplicands(){
          num1 = 1 + (int) (Math.random() * 9 );
          num2 = 1 + (int) (Math.random() * 9 );
       }//end of getMultiplicands
       public void poseQuestion(){
          String query = "";
          query = ("how much is " +num1+ " x " +num2 + " ?");
          message = query;
          repaint();
       }//end of poseQuestion
       public void paint(Graphics g){
          super.paint(g);
          getAppletContext().showStatus(message);
       }//end of paint
       public int checkAnswer(int r){
          //r contains users response to the question
          //if they answered correctly mark = 1, incorrect mark = 0;
          if (r == (num1*num2))
             return 1;
          else
             return 0;
       }//end of checkAnswer  
       public void teacher( int m){
          //the users mark, 0 or 1, is contained in m
          String talk = "";
          if (m == 0)
             talk = ("No - that is NOT correct");
          if (m == 1)
             talk = ("excellent!!");
          message = talk;
          repaint();        //to display the teachers comments you must repaint
       }//end of teacher
    }//end of Applet

    Purpose of pgm: to teach kids the mulitplication
    table. A question appears in the status bar "how much
    is 7 x 5", kid answers, answer is checked. If answer
    is correct display in status bar "excellent" else
    answer is wrong so display "incorrect". If the answer
    is incorrect display the same question in the status
    bar.
    my problem: The teachers responses are not appearing
    in the status bar� how can i fix this? Compounding
    problem: all questions & responses MUST be displayed
    in the status bar. (the questions ARE appearing in the
    status bar).Sympton: Responses are not displayed.
    Cause: The next question is overwriting the previous response.
    Cure 1: Incorporate the previous response in the next question.
    Cure 2: Don't use the status bar.
    The browser status bar is small, hard to read, and isn't guaranteed to be visible. In IE, the status bar can be disabled in the view menu, and it is also hidden in full-screen mode. Further, it can only hold a single string, which is easily overwritten.
    To guarantee that a user can see a message, it is recommended that the message be displayed in an appropriate way in the applet. A simple solution would be to place the question in a label above the answer, and the response in a label above the question.
    For the first question, you set the text of the question label, and leave the response label blank. For each successive question, update the question and response labels as necessary.
    To position the labels correctly, take a look at the AWT tutorials, in particular the section on LayoutManagers on the sun website. GridBagLayout would work, but might be tricky to set up... a combination of GridLayout, nested Panels and FlowLayouts may be the simplest technique.
    A final note, you are using swing in your applet... most of the browsers that are connected to the internet are using Java 1.1.x, which does not include the swing classes. To reach the widest audience, you should use only AWT components - particularly for school-based situations... if your users have access to upgrade their machine setup, then requiring them to download the Java plugin is a feasible solution to allow a larger feature set.
    Regards,
    -Troy

  • Problem detecting when four in a row has been acheived

    Hi, i am having problems with my game of connect 4 and would like some help, i have look through the other forum posts but cant seem to find an answer that works. I am having problems getting the program to output " Winner" when four values in a row of the array are the same.
    If someone could give me some pointers id be very gratefull.
    Thanks.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class FourInARow extends JApplet implements ActionListener
         Panel top;
         Panel main;
         Panel bottom;
         JButton[] columnButtons;
         JPanel[][] gridPanel;
         int[][] win;
         JButton reset;
         int Count;
         int levelA;
         int levelB;
         int levelC;
         int levelD;
         int levelE;
         int levelF;
         int levelG;
         boolean hasAWinner = false;
         public void init()
              Count = 0;
              levelA = 5;
              levelB = 5;
              levelC = 5;
              levelD = 5;
              levelE = 5;
              levelF = 5;
              levelG = 5;
              setLayout(new BorderLayout());
              top = new Panel();
              add(top, BorderLayout.NORTH);
              top.setBackground(Color.black);
              top.setLayout(new GridLayout(1,7));
              columnButtons = new JButton[7];
              for(int i=0; i<7; i++)
                        columnButtons[i] = new JButton("X");
                        top.add(columnButtons);
                        columnButtons[i].addActionListener(this);
              main = new Panel();
              add(main, BorderLayout.CENTER);
              main.setBackground(Color.black);
              main.setLayout(new GridLayout(6,7,2,2));
              gridPanel = new JPanel[6][7];
              for(int i=0; i<6; i++)
                   for(int j=0; j<7; j++)
                        gridPanel[i][j] = new JPanel();
                        main.add(gridPanel[i][j]);
                        gridPanel[i][j].setBackground(Color.blue);
                        gridPanel[i][j].setLayout(new FlowLayout());
              bottom = new Panel();
              add(bottom, BorderLayout.SOUTH);
              bottom.setBackground(Color.black);
              reset = new JButton("RESET");
              bottom.add(reset);
              reset.addActionListener(this);
              win= new int[6][7];
         public void actionPerformed(ActionEvent ev)
              Counter1 counter;
              if(ev.getSource() == columnButtons[0])
                   counter = new Counter1(Count);
                   gridPanel[levelA][0].add(counter);
                   Count ++;
                   levelA--;
                   System.out.println("col 1 and Count=" + Count);
              if(ev.getSource() == columnButtons[1])
                   counter = new Counter1(Count);
                   gridPanel[levelB][1].add(counter);
                   Count ++;
                   levelB--;
                   System.out.println("col 2 and Count=" + Count);
              if(ev.getSource() == columnButtons[2])
                   counter = new Counter1(Count);
                   gridPanel[levelC][2].add(counter);
                   Count ++;
                   levelC--;
                   System.out.println("Col 3 and Count=" + Count);
              if(ev.getSource() == columnButtons[3])
                   counter = new Counter1(Count);
                   gridPanel[levelD][3].add(counter);
                   Count ++;
                   levelD--;
                   System.out.println("col 4 and Count=" + Count);
              if(ev.getSource() == columnButtons[4])
                   counter = new Counter1(Count);
                   gridPanel[levelE][4].add(counter);
                   Count ++;
                   levelE--;
                   System.out.println("col 5 and Count=" + Count);
              if(ev.getSource() == columnButtons[5])
                   counter = new Counter1(Count);
                   gridPanel[levelF][5].add(counter);
                   Count ++;
                   levelF--;
                   System.out.println("Col 6 and Count=" + Count);
              if(ev.getSource() == columnButtons[6])
                   counter = new Counter1(Count);
                   gridPanel[levelG][6].add(counter);
                   Count ++;
                   levelG--;
                   System.out.println("Col 7 and Count=" + Count);
              if(ev.getSource() == reset)
                   Count = 0;
                   levelA = 5;
                   levelB = 5;
                   levelC = 5;
                   levelD = 5;
                   levelE = 5;
                   levelF = 5;
                   levelG = 5;
                   System.out.println("Restart and count = " + Count);
              if(Count %2 == 0)
                   System.out.println("Player 1");
                   showStatus("Player 1");
              else
                   System.out.println("Player2");
                   showStatus("Player 2");
              if(Count >= 42)
                   System.out.println("Draw Please Restart");
                   showStatus("Draw Please Restart");
              if(Count %2 == 0 && ev.getSource() == columnButtons[0])
                   win[levelA+1][0]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[0])
                   win[levelA+1][0]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[1])
                   win[levelB+1][1]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[1])
                   win[levelB+1][1]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[2])
                   win[levelC+1][2]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[2])
                   win[levelC+1][2]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[3])
                   win[levelD+1][3]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[3])
                   win[levelD+1][3]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[4])
                   win[levelE+1][4]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[4])
                   win[levelE+1][4]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[5])
                   win[levelF+1][5]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[5])
                   win[levelF+1][5]=2;
              if(Count %2 == 0 && ev.getSource() == columnButtons[6])
                   win[levelG+1][6]=1;
              else if(Count %2 == 1 && ev.getSource() == columnButtons[6])
                   win[levelG+1][6]=2;
              repaint();
              paintAll(this.getGraphics());
              for(int i=0; i<6; i++)
                   for(int j=0; j<7; j++)
                        System.out.print(win[i][j]);
                        /*if(win[i][j] != 0 &&
                        win[i][j]== win[i+1][j] &&
                        win[i][j]== win[i+2][j] &&
                        win[i][j]== win[i+3][j])
                   System.out.println();
    class Counter1 extends JPanel
         int Count;
         public Counter1(int Count)
              this.Count = Count;
         public void paintComponent (Graphics graf)
              if(Count %2 == 0)
                   graf.setColor(Color.red);
                   graf.fillOval(1,1,this.getWidth(),this.getHeight());
              else
                   graf.setColor(Color.yellow);
                   graf.fillOval(1,1,this.getWidth(),this.getHeight());

    Cheers for the ideas guys, i was trying to do something like this:
              for(int i=0; i<6; i++)
                   for(int j=0; j<7; j++)
                        if(win[i][j] != 0 &&
                           win[i][j]== win[i+1][j] &&
                           win[i][j]== win[i+2][j] &&
                           win[i][j]== win[i+3][j])
                                                                           //I would have a bit of code here that changed the value of a boolean variable
              }but it wont compile, any way of doing something along thesed lines?
    Edited by: zakyg on Mar 12, 2008 6:55 AM

  • Problem using the applet for the game design!

    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Random;
    /* <applet code="Gameshtap2.class" width ="500" height="600">
    </applet>
    public class Gameshtap2 extends Applet implements ActionListener,KeyListener,MouseListener,MouseMotionListener,Runnable
    Thread t;
    Button b1,b2;
    int y=0;
    int Xpos=480;
    char keyChar='A';
    public void init()
    t=new Thread();
    b1=new Button("Start");
    b2=new Button("Stop");
    add(b1);
    add(b2);
    b1.addActionListener(this);
    b2.addActionListener(this);
    addKeyListener(this);
    this.requestFocus();
    this.setFocusable(true);
    addMouseListener(this);
    addMouseMotionListener(this);
    public void paint(Graphics g)
    int no;
    g.drawArc(0,y,100,100,30,300);
    g.drawLine(50,y+50,50+(int)(50*Math.cos(3.14159/6)),y+50-(int)(50*Math.sin(3.14159/6)));
    g.drawLine(50,y+50,50+(int)(50*Math.cos(3.14159/6)),y+50+(int)(50*Math.sin(3.14159/6))); 
    for(int i=0;i<10;i++)
       no=(int)(Math.random()*600);
       g.drawOval(Xpos,no,10,10);
       if(Xpos<=480 && Xpos>=0)
         Xpos=Xpos--;
        if(Xpos>480 || Xpos<0)
          Xpos=480;
    public void actionPerformed(ActionEvent e)
    if(e.getSource()==b1)
         if (t == null)
              t=new Thread(this);
              t.start();       
    } else if(e.getSource()==b2)
         if(t!=null)    
                  t = null;
    public synchronized void keyPressed(KeyEvent ep)
    switch(ep.getKeyCode())
         case KeyEvent.VK_DOWN:y+=10;
                              if(y>=490)
                                 y=0;
                              else if(y<=0)
                              y=490;               
                   repaint();     
                            break;    
        case KeyEvent.VK_UP:y-=10;
                              if(y>=490)
                                 y=0;
                              else if(y<=0)
                              y=490;     
                   repaint();
                            break;    
       default:keyChar=ep.getKeyChar();
    public  synchronized void run()
    while(true)
         repaint();
       try
            t.sleep((int)(Math.random()*200));
       catch(InterruptedException e1)
           e1.printStackTrace();
    public void keyReleased(KeyEvent er)
       System.out.println("released");
    public void keyTyped(KeyEvent er)
       System.out.println("Typed");
    public void mouseClicked(MouseEvent me)
      int m=me.getX();
      int p=me.getY();
       showStatus("X coordinate is:"+m+"Y coordinate is:"+p);
    public void mouseMoved(MouseEvent mp)
    public void mouseDragged(MouseEvent mn)
    public void mousePressed(MouseEvent mr)
    public void mouseReleased(MouseEvent mc)
    public void mouseExited(MouseEvent ma)
    public void mouseEntered(MouseEvent ml)
    we are trying to implement the game where the big arc controlled by the keyboard is gobbyling up
    the smaller circles,but we are unable to run this program
    regards,
    Jack

    It would be better if you posted this in one of the GUI forums.
    Those forums are for addressing programming problems related to general java issues. Which is what you have.
    Also +"unable to run this program"+ doesn't explain the problem unless you don't know what appletviewer is.

Maybe you are looking for