The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

java ui components using buttons

Posted by jerry on December 09, 2000 at 6:00 AM

greetings

i am trying to add a button to a choice menu so that when i click on it will open the window so a user will be able to choose a selection.

i can create the button and the chocie menu , but when it comes to the action() event i am not sure what to due. the program fails to complie the way it is. i have tried several public class ChoiceMenu types but still no luck.
****************************************************************

import java.awt.*;

public class Menus extends java.applet.Applet {

public void init() {
setBackground(Color.yellow);

add(new Button("Motorcycles"));

Choice c = new Choice();

c.addItem("1967 Honda NightRider");
c.addItem("1994 Suzuki Ninja");
c.addItem("1972 Yamaha Striker");
c.addItem("None");

add(c);

}

public boolean action(Event evt, Object arg) {
if(evt.target instanceof Button)
Bikes((String)arg);

return true;


}

void Bikes(String bname) {

if (bname.equals("Motorcycles")) handleChoice(new Choice());

}


}
*****************************************************************************

after i name the arg. for the button , and create the new method . i cant find a way to call the arg. i have tried replacing new choice with just arg. that didnt work , then i added (String)arg , again that didnt work.

so i would greatly need any help you can give.

thank you jerry



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us