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
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
Get step-by-step solutions from verified subject matter experts
