Question: application that allows a user to select a country from a list box that contains the following seven options. After the user makes a selection,

application that allows a user to select a country from a list box that contains the following seven options. After the user makes a selection, display the country's capital city.

CountryCapita

lAustriaVienna

CanadaToronto

EnglandLondon

FranceParis

ItalyRome

MexicoMexico City

SpainMadrid

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class JCapitals extends JFrame implements ItemListener {

FlowLayout flow = new FlowLayout();

JLabel countryLabel = new JLabel("Select a country");

JComboBox countryBox = new JComboBox();

JTextField capitalField = new JTextField(25);

// code here

public JCapitals() {

// code here

}

public static void main(String[] arguments) {

JCapitals cframe = new JCapitals();

cframe.setSize(400, 150);

cframe.setVisible(true);

}

@Override

public void itemStateChanged(ItemEvent list) {

// code here

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!