+1 vote
in Mathematics by kratos

Design a GUI application that displays food types in a combo box and foods pertaining to selected type in a list box.

Upon selecting a specific fopod, its detail (such as calories, *** content etc.) are displayed in a separate dialog.

1 Answer

+1 vote
by kratos
 
Best answer

import javax. swing. Default List Model;

import javax. swing. J Option Pane;

// combo box

private void j Combo Box 1 Item State Changed(java. awt. event. Item Event evt) {

String str=j Combo Box 1. get Selected Item().to String();

if(str. equals("Dairy"))

{

Default List Model dlm=new Default List Model();

dlm. add Element("Cheddar Cheese");

dlm. add Element("Processed Cheese");

dlm. add Element("Cottage Cheese");

dlm. add Element("Milk");

dlm. add Element("Curd");

dlm. add Element("Ghee");

j List 1. set Model(dlm);

}

// same process for other food type

}

// ok button

private void j Button 1 Action Performed(java. awt. event. Action Event evt) {

// TODO add your handling code here:

String msg=j List 1. get Selected Value().to String();

if(msg. equals("Cheddar Cheese"))

{

J Option Pane. show Message Dialog(null, "print the calories,*** etc");

}

// same process for other option

}

// Exit Button

private void j Button 2 Action Performed(java. awt. event. Action Event evt) {

// TODO add your handling code here:

System.exit(0);

}

...