Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-06-2008, 02:36 PM
iuna's Avatar
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
iuna is on a distinguished road
Default deprecated method.. help!
Can someone please help me in converting the deprecated method handleEvent() to processEvent() in this program? I don't know how..

attached is the program I'm working on.. thanks for the help
Attached Files:
File Type: zip Game.zip (28.5 KB, 8 views)
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 09-06-2008, 03:50 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
What have you tried so far?
What does the doc say for the new method?
Why are you using such low level methods? This must be a VERY old program.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 06:45 AM
iuna's Avatar
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
iuna is on a distinguished road
Default
it says that I have to use protected void processEvent(AWTEvent e)..

seems like I have to create an AWTEvent method.. does it mean that I just have to copy all the contents of handleEvent into the AWTEvent?

waa.. O_O
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 02:37 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
There is a problem with Game.zip file. I can't open it after its downloaded.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-07-2008, 04:02 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,190
Rep Power: 5
Fubarable is on a distinguished road
Default
I opened it with 7-zip, but it was created using AWT which I don't know:
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-07-2008, 04:23 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Did you read the Java document? It should be clearly explain what you have to do.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-07-2008, 04:47 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
Why are you using such low level methods?
You should rewrite the code to use current techniques such as Listeners.
What events does the code handle?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 09-08-2008, 10:42 AM
iuna's Avatar
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
iuna is on a distinguished road
Default
sorry for the corrupted file..

it can be downloaded at mediafire[dot]com/download[dot]php?2scvqbhzg6x

(seems like I can't post links here)
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 09-08-2008, 10:46 AM
iuna's Avatar
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
iuna is on a distinguished road
Default
Originally Posted by Norm View Post
You should rewrite the code to use current techniques such as Listeners.
What events does the code handle?
I think it handles the "Start", "Submit" and "Accept" events
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 09-08-2008, 10:51 AM
iuna's Avatar
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
iuna is on a distinguished road
Default
Originally Posted by Eranga View Post
Did you read the Java document? It should be clearly explain what you have to do.
yes I've read it but I'm still new to Java so I'm still lost with the API..
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 09-08-2008, 02:07 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
"Start", "Submit" and "Accept" events
Those don't sound like events. Are they the labels on buttons?
Buttons create ActionEvents which are handled by actionListeners.

The deprecation messages are only warnings. You can ignore them for now. The program should execute. As you learn java you will learn about events and listeners and will be able to rewrite the program to use them instead of using handleEvent
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 09-08-2008, 08:38 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,389
Rep Power: 3
hardwired is on a distinguished road
Default
Code:
//import java.applet.*;
import java.awt.*;
import java.awt.event.*;
//import java.lang.Math;

public class BotNav extends Panel implements ActionListener,
                                             ItemListener {
    Matches parent;
    TextField counter;
    Label lcounter;
    Label lchoice;
    Choice choice;	
    Button submit;
    Button start;
    Button accept;
    int selected = 1;
    String content;

    BotNav(Matches contr) {
        super();
        parent = contr;
        counter = new TextField(3);
        counter.setEditable(false);
        lcounter = new Label("       Counter:");
        lchoice = new Label("     Your turn:");
        choice = new Choice();
        choice.addItem("1");
        choice.addItem("2");
        choice.addItem("3");
        choice.addItemListener(this);
        start = new Button("Start");
        submit = new Button("Submit");
        accept = new Button("Accept");
        start.addActionListener(this);
        submit.addActionListener(this);
        accept.addActionListener(this);
        setLayout(new GridLayout(1,7));
        add(start);
        add(lcounter);
        add(counter);
        add(accept);
        add(lchoice);
        add(choice);
        add(submit);
    }

    public int getSelected() {
        return this.selected;
    }

    public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            int result = parent.getCount();
            if (result > 1) {
                selected = choice.getSelectedIndex() + 1;
                if ((result - selected) < 1) {
                    parent.textField.setText("EEEEK ! Are you crazy ?");
                } else {
                    parent.textField.setText("Your choice is " + selected +
                                             ", you can submit it !");
                }
            }
        }
    }

    public void actionPerformed(ActionEvent e) {
        Button button = (Button)e.getSource();
        String ac = button.getActionCommand();
        if (ac.equals("Start")) {
            parent.setCount(0);
            parent.board.repaint();
            parent.textField.setText("Ok...now choose count of matches");
            counter.setEditable(true);
            counter.requestFocus();
        }
        if (ac.equals("Accept")) {
            boolean edit = counter.isEditable();
            if (edit) {
                content = counter.getText();
                int count = Integer.valueOf(content).intValue();
                if ((count > 60) || (count < 2)) {
                    parent.textField.setText("Choose min. 2 and max. " +
                                             "60 matches");
                    counter.requestFocus();
                } else {
                    counter.setEditable(false);
                    counter.transferFocus();
                    parent.setCount(count);
                    parent.board.repaint();
                    parent.textField.setText("Now it's your turn");
                }
            }
        }
        if (ac.equals("Submit")) {
            int newcount = parent.getCount();
            if (newcount > 1) {
                if ((newcount - selected) < 1) {
                    if (newcount == 3) {
                        parent.textField.setText("Take 2 !!!");
                    } else {
                        parent.textField.setText("Take 1 !!!"); 
                    }
                } else {
                    newcount -= selected;
                    parent.setCount(newcount);
                    parent.board.repaint();
                    counter.setText((String.valueOf(newcount).toString()));
                    parent.myTurn();
                }
            }
        }
    }
}
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deprecated annotation JavaForums Java Blogs 0 07-16-2008 01:40 PM
I need help with a deprecated program mikau New To Java 0 02-13-2008 09:34 AM
getYear deprecated method ravian New To Java 1 01-28-2008 10:35 AM
Using Deprecated Methods ravian New To Java 3 11-23-2007 07:58 PM
method size is deprecated oregon New To Java 4 08-05-2007 05:59 PM


All times are GMT +2. The time now is 06:31 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org