473,385 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to fix this?

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
Nov 4 '07 #1
2 1321
JosAH
11,448 Expert 8TB
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?
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
Nov 4 '07 #2
heat84
118 100+
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 .
Nov 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
6
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE...
1
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.