Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Question? uses or overrides a deprecated API.

807598Apr 24 2006 — edited Apr 24 2006
Ok first off I an new to Java programming so when compiling a program I recived the following message:

Note: C:\Documents and Settings\My Documents\My Digital Editions\Java Programming\MessageDemo.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Tool completed successfully

Even with this message the program still runs fine but I wanted to know what I did wrong the program seems to be written write.

Does anyone know why this is happening.

Here is the code:

import java.awt.*;
import java.awt.event.*;

public class MessageDemo extends Frame implements ActionListener
{
Button b;


public static void main(String[] args)
{

MessageDemo mdd = new MessageDemo();
mdd.setVisible(true);
mdd.setSize(250, 200);
}

MessageDemo()
{

super("Messager Demo");


// Set layout manager
setLayout(new FlowLayout(FlowLayout.CENTER, 120, 50));

// Create button
b = new Button("Message Dialog");
b.addActionListener(this);
add(b);

// Anonymous inner class handles window events
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}

public void actionPerformed(ActionEvent ae)
{
String message = "This is the message";
MessageDialog md = new MessageDialog(this, "Message Dialog", true, message);
md.show();
}
}

class MessageDialog extends Dialog implements ActionListener
{
Button ok;

MessageDialog(Frame parent, String title, boolean mode, String message)
{
super(parent, title, mode);

// Create and add "Center" panel
Panel pc = new Panel();
Label label = new Label(message);
pc.add(label);
add(pc, "Center");

// Create and add "South" panel
Panel ps = new Panel();
ok = new Button("OK");
ok.addActionListener(this);
ps.add(ok);
add(ps, "South");

// Lay out components and set the initial size
// of this dialog box
pack();

// Anonymous inner class handles window events
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}

public Insets getInsets()
{
return new Insets(20, 20, 20, 20);
}


public void actionPerformed(ActionEvent ae)
{
dispose();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2006
Added on Apr 24 2006
4 comments
184 views