How to fix this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frozzenn
    New Member
    • Oct 2007
    • 6

    #1

    How to fix this?

    hi all,

    After compiling I recieve this msg:
    Note: C:\Documents and Settings\Evalda s\Desktop\moksl as\JAVA 2kursas\bandyma s\sample5.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecati on for details.

    Tool completed successfully

    and I can't run an applet. Whats wrong?
    Thats a code :
    import java.awt.*;
    import java.awt.event. *;
    import javax.swing.*;

    public class sample5 extends JFrame{

    JLabel L1,L2,L3,L4,L5, L6;
    JTextField T1,T2,T3,T4,T5, T6;
    JButton B1,B2;
    JLabel message;
    JTextArea TA;
    JPanel panel;
    JFrame frame;

    String [] Names = new String [35] ;
    double [] GAvg = new double [35] ;

    public sample5 () {
    frame = new JFrame ("Compute average for a 35 student section");
    frame.setDefaul tCloseOperation (JFrame.EXIT_ON _CLOSE);

    // create labels
    L1 = new JLabel ("Name");
    L2 = new JLabel ("MT1");
    L3 = new JLabel ("MT2");
    L4 = new JLabel ("MT3");
    L5 = new JLabel ("Lab");
    L6 = new JLabel ("Quiz");
    message = new JLabel ("");

    //create text fields
    T1 = new JTextField (10);
    T2 = new JTextField (5);
    T3 = new JTextField (5);
    T4 = new JTextField (5);
    T5 = new JTextField (5);
    T6 = new JTextField (5);

    //create buttons
    B1 = new JButton("New student");
    B2 = new JButton("List") ;

    //create text area with 40 rows and 50 columns
    TA = new JTextArea(40,50 );

    //create a ButtonListener and make it listen for the buttons to be pressed
    ButtonListener lsn = new ButtonListener () ;
    B1.addActionLis tener (lsn) ;
    B2.addActionLis tener (lsn) ;

    //set up the JPanel to go on the JFrame
    panel = new JPanel();
    panel.setPrefer redSize (new Dimension(600, 500));
    panel.setBackgr ound (new Color (60,160,100));

    //add all the GUI components to the panel
    panel.add (L1) ; panel.add (T1) ;
    panel.add (L2) ; panel.add (T2) ;
    panel.add (L3) ; panel.add (T3) ;
    panel.add (L4) ; panel.add (T4) ;
    panel.add (L5) ; panel.add (T5) ;
    panel.add (L6) ; panel.add (T6) ;

    panel.add (message);

    panel.add (B1) ;
    panel.add (B2) ;

    panel.add (TA) ;

    //add the panel to the frame
    frame.getConten tPane().add (panel);

    //display the frame
    frame.pack();
    frame.show();

    }

    // Represents an action listener for the calculate button.

    private class ButtonListener implements ActionListener {
    int count=0;

    public void actionPerformed (ActionEvent event)
    {

    JButton buttonObj = (JButton) event.getSource ();

    if (buttonObj == B1) {
    if (count>34)
    message.setText ("No more students; press List button!");
    else {
    String isim = T1.getText();
    double mt1 = Double.parseDou ble(T2.getText( ));
    double mt2 = Double.parseDou ble(T3.getText( ));
    double mt3 = Double.parseDou ble(T4.getText( ));
    double lab = Double.parseDou ble(T5.getText( ));
    double quiz = Double.parseDou ble(T6.getText( ));

    if (mt1<0||mt2<0|| mt3<0||lab<0||q uiz<0||
    mt1>100||mt2>10 0||mt3>100||lab >100||quiz>10 0)
    message.setText ("grades must be between 0 and 100");
    else {
    message.setText ("");
    Names[count] = isim;
    GAvg[count] = mt1*0.25+mt2*0. 25+mt3*0.25+
    lab*0.2+quiz*0. 05;
    count++;
    }

    }
    }//B1

    else {//B2
    sortD(Names,GAv g,count);
    displayArray (Names,GAvg,cou nt);
    double mean = findsMean(GAvg, count);
    TA.append("Aver age of GAvg\'s : ");
    TA.append(""+me an);
    count=0;
    TA.append("\n") ;

    }

    }//actionPerformed

    }//ButtonListener


    // the following loop displays the values of the elements of a given array
    private void displayArray (String[] Sa,double[] W,int N) {
    int k;

    TA.append("Name \tGavg\n");
    TA.append("==== \t====\n");

    for (k=0; k<N; k++)
    TA.append(Sa[k]+'\t'+W[k]+"\n");
    TA.append("\n") ;
    }

    private double findsMean(doubl e[] x,int N) {
    int k;
    double sum=0;
    for (k=0;k<N;k++)
    sum += x[k];
    return (sum/N);
    }

    // the following method sorts the array passed as its parameter
    private void sortD (String [] Sa, double[] Y, int t) {

    int i, j ;
    double temp;
    String S;

    for (i=0; i<(t-1); i++)
    for (j=i+1; j<t; j++)
    if ( Y[j] > Y[i] ) {
    temp = Y[j] ;
    Y[j] = Y[i] ;
    Y[i] = temp ;
    S = Sa[j] ;
    Sa[j] = Sa[i] ;
    Sa[i] = S ;
    }//if
    } //sortD

    }//Sample5
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by frozzenn
    hi all,

    After compiling I recieve this msg:
    Note: C:\Documents and Settings\Evalda s\Desktop\moksl as\JAVA 2kursas\bandyma s\sample5.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecati on for details.

    Tool completed successfully

    and I can't run an applet. Whats wrong?
    Your compiler also told you exactly the line number and method or class that is
    deprecated. Check the API documentation for that class or method and read what
    the alternatives are. Deprecated methods and classes are not guaranteed to exist
    in later versions of Java so you shouldn't use them although they might work in
    your current Java version.

    kind regards,

    Jos

    Comment

    • heat84
      New Member
      • Nov 2007
      • 118

      #3
      Add your classpath on the environmental variables.

      Compile using javac on the command line so that you may be able to see the output on the command prompt.

      javac -Xlint classname.java

      You will be able to see the details .

      Comment

      Working...