Results 1 to 12 of 12
Thread: deprecated method.. help!
- 09-06-2008, 02:36 PM #1
- 09-06-2008, 03:50 PM #2
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, 06:45 AM #3
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, 02:37 PM #4
There is a problem with Game.zip file. I can't open it after its downloaded.
-
I opened it with 7-zip, but it was created using AWT which I don't know:
- 09-07-2008, 04:23 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you read the Java document? It should be clearly explain what you have to do.
- 09-07-2008, 04:47 PM #7
You should rewrite the code to use current techniques such as Listeners.Why are you using such low level methods?
What events does the code handle?
- 09-08-2008, 10:42 AM #8
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, 10:46 AM #9
- 09-08-2008, 10:51 AM #10
- 09-08-2008, 02:07 PM #11
Those don't sound like events. Are they the labels on buttons?"Start", "Submit" and "Accept" events
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, 08:38 PM #12
Java 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(); } } } } }
Similar Threads
-
getYear deprecated method
By ravian in forum New To JavaReplies: 5Last Post: 01-05-2011, 08:50 AM -
I need help with a deprecated program
By mikau in forum New To JavaReplies: 0Last Post: 02-13-2008, 09:34 AM -
Using Deprecated Methods
By ravian in forum New To JavaReplies: 3Last Post: 11-23-2007, 07:58 PM -
method size is deprecated
By oregon in forum New To JavaReplies: 4Last Post: 08-05-2007, 05:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks