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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started