freelanceprogrammers.org Forum Index » Java

Depreciation Version error?


View user's profile Post To page top
juliana_lewis Posted: Fri Apr 23, 2004 1:57 pm


Joined: 23 Apr 2004

Posts: 3
Depreciation Version error?
hi.
i am trying to excute this program, whose basic theme is to play an
audio clip in an applet, when i try to run it , it excutes with the
error message of the depreciated version, can someone tell me or
correctify this bug. i will be more then greatful.

import javax.swing.*;
import java.awt.* ;
import java.net.* ;
import java.applet.* ;

public class Sound1 extends Applet
{
Button b1 ;

public void init()
{
BorderLayout layout = new BorderLayout();
setLayout( layout );

Font font = new Font("TimesRoman", Font.BOLD, 32 );
setFont( font );

b1 = new Button("Play Sound" );
add("Center", b1 );
resize( 250, 250 );
}

public boolean action( Event evt, Object arg )
{
if( evt.target instanceof Button )
{
URL codebase = getCodeBase();
play( codebase, "ben.au");
}
return true ;
}
}

I will be looking forward towards the reply.
Regards
Jules
Reply with quote
Send private message
View user's profile Post To page top
hazins Posted: Fri Apr 23, 2004 6:42 pm


Joined: 16 Apr 2004

Posts: 15
Depreciation Version error?
Juliana,

First of all, I just wanted to mention that whenever a method is
deprecated - the compiler only gives you a WARNING, so your program will
still run fine. All it`s saying is that one day Java might stop
supporting it.

I fixed your code up to do it the way it`s supposed to be done:

import javax.swing.*;
import java.awt.* ;
import java.awt.event.*;
import java.net.* ;
import java.applet.* ;

public class Sound1 extends Applet
{
Button b1 ;

public void init()
{
BorderLayout layout = new BorderLayout();
setLayout( layout );

Font font = new Font("TimesRoman", Font.BOLD, 32 );
setFont( font );

b1 = new Button("Play Sound" );
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
URL codebase = getCodeBase();
play( codebase, "ben.au");
}
});
add("Center", b1 );
resize( 250, 250 );
}
}




>>> juliana_lewis@... 4/23/2004 4:57:00 AM >>>
hi.
i am trying to excute this program, whose basic theme is to play an
audio clip in an applet, when i try to run it , it excutes with the
error message of the depreciated version, can someone tell me or
correctify this bug. i will be more then greatful.

import javax.swing.*;
import java.awt.* ;
import java.net.* ;
import java.applet.* ;

public class Sound1 extends Applet
{
Button b1 ;

public void init()
{
BorderLayout layout = new BorderLayout();
setLayout( layout );

Font font = new Font("TimesRoman", Font.BOLD, 32 );
setFont( font );

b1 = new Button("Play Sound" );
add("Center", b1 );
resize( 250, 250 );
}

public boolean action( Event evt, Object arg )
{
if( evt.target instanceof Button )
{
URL codebase = getCodeBase();
play( codebase, "ben.au");
}
return true ;
}
}

I will be looking forward towards the reply.
Regards
Jules




------------------------ Yahoo! Groups Sponsor


Yahoo! Groups Links
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help