Practical 2: Write a program to design a form using the components List and Choice.

1) Write a program to display following output:
Choice in Java AWT

Ans:

import java.awt.*;

public class ChoiceDemo
{
	public static void main(String args[])
	{
		Frame f = new Frame();
		f.setSize(400,400);
		f.setVisible(true);
		f.setLayout(new FlowLayout());
		
		Choice c = new Choice();
		c.add("Maths");
		c.add("Physics");
		c.add("Chemistry");	
	
		f.add(c);
	}
}


2) Develop applet/application to select multiple names of news papers.
Ans:
import java.awt.*;
import java.applet.*;

public class ListDemo extends Applet
{
	public void init()
	{
		List c = new List();
		c.setMultipleSelections(true);
		c.add("The Times of India");
		c.add("Lokmat");
		c.add("Divya Marathi");
		c.add("Navbharat Times");	
		add(c);
	}
}

/*
 
 
*/

Output:
List in Java AWT

Previous
Next Post »