English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

following are the list of program .plz help me write a program.
1.program to add 4 buttons on an applet with caption "one" ,"twom","three","four" using GridLayout ?
2.prog to create an appplet having 3 buttons with captions RED,GREEN & BLUE when a button is clicked the applet background color will change accordingly ?
3.prog to display the contents of a file on screen ?
4.prog to send user name to the server and server will send welcome username to the client ?

2007-03-09 22:37:15 · 2 answers · asked by humtummonkey 3 in Computers & Internet Programming & Design

2 answers

Ok so these are ur problems..

1) ok for 1st question create a public class extending Applet class and declare button variables (e.g. private Button cmdok) in it. After that in the init() method create the objects of these variables (cmdok =new Button("Ok"));
Now set the layout to GridLayout (e.g. this.setLayout(new GridLaout(2,2));
Now add these buttons in the container means in Applet using the add() method (e.g. this.add(cmdok));
Now compile the class and create a HTML page embedding the class in the HTML page & finally run this page from a java enabled browser. Thats it...

2) for 2nd prob. just repeat above with three buttons excluding the layout method.
Now for the class implement the ActionListener interface
(eg. public class MyApplet extends Applet implements ActionListener) and add the command listener (e.g. cmdok.addCommandListener(this);) and add the method
commandAction(eg. public void commandAction(ActionEvent event))
Now in this method get the source in the if...else loop
(eg. if (event.getSource()==cmdok){this.setBackground(Color.RED));
Thats it...

For 3rd and 4th I dont know the exact answer but u can get the same at
http://www.java-tips.org/java-se-tips/java.io/how-to-read-file-in-java.html

2007-03-12 23:11:33 · answer #1 · answered by smart_aju2007 1 · 0 0

Hahaha you cant even admit Arsenal deserved their win. Im gonna remeber you asserting all this crap approximately them, and dont come again in 2 weeks asserting you're a very good fan. As for Manutd Villa, i are awaiting 2-a million to Villa. Eidt: say what you opt for for, yet you didnt even watch the Arsenal activity, so something you're saying sounds truly stupid. As for what ever I say, I also have a very good too, so why dont you attempt to close up. Youre making no pals in any respect.

2016-12-14 15:26:21 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers