hi all,
After compiling I recieve this msg:
Note: C:\Documents and Settings\Evaldas\Desktop\mokslas\JAVA 2kursas\bandymas\sample5.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation 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.setDefaultCloseOperation (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.addActionListener (lsn) ;
B2.addActionListener (lsn) ;
//set up the JPanel to go on the JFrame
panel = new JPanel();
panel.setPreferredSize (new Dimension(600, 500));
panel.setBackground (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.getContentPane().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.parseDouble(T2.getText());
double mt2 = Double.parseDouble(T3.getText());
double mt3 = Double.parseDouble(T4.getText());
double lab = Double.parseDouble(T5.getText());
double quiz = Double.parseDouble(T6.getText());
if (mt1<0||mt2<0||mt3<0||lab<0||quiz<0||
mt1>100||mt2>100||mt3>100||lab>100||quiz>100)
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,GAvg,count);
displayArray (Names,GAvg,count);
double mean = findsMean(GAvg,count);
TA.append("Average of GAvg\'s : ");
TA.append(""+mean);
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(double[] 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