|
|
|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

09-06-2008, 04:36 PM
|
 |
Member
|
|
Join Date: Sep 2008
Posts: 16
|
|
|
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
|
|

09-06-2008, 05:50 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
|
|
|
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.
|
|

09-07-2008, 08:45 AM
|
 |
Member
|
|
Join Date: Sep 2008
Posts: 16
|
|
|
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
|
|

09-07-2008, 04:37 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
|
|
|
There is a problem with Game.zip file. I can't open it after its downloaded.
|
|

09-07-2008, 06:02 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Posts: 870
|
|
|
I opened it with 7-zip, but it was created using AWT which I don't know:
|
|

09-07-2008, 06:23 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,545
|
|
|
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.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? 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.
|
|

09-07-2008, 06:47 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
|
|
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?
|
|

09-08-2008, 12:42 PM
|
 |
Member
|
|
Join Date: Sep 2008
Posts: 16
|
|
|
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)
|
|

09-08-2008, 12:46 PM
|
 |
Member
|
|
Join Date: Sep 2008
Posts: 16
|
|
Originally Posted by Norm
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
|
|

09-08-2008, 12:51 PM
|
 |
Member
|
|
Join Date: Sep 2008
Posts: 16
|
|
Originally Posted by Eranga
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..
|
|

09-08-2008, 04:07 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
|
|
"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
|
|

09-08-2008, 10:38 PM
|
|
Senior Member
|
|
Join Date: Jul 2007
Posts: 1,222
|
|
//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();
}
}
}
}
}
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
All times are GMT +3. The time now is 07:46 PM.
|
|
VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org