Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Write an application that allows a user to select one of at least five television shows to watch on demand. When the user selects

a. Write an application that allows a user to select one of at least five television shows to watch on demand. When the user selects a show, display a brief synopsis. Save the file as JTVDownload.java.

b. Change the JTVDownload application to include an editable combo box. Allow the user to type the name of a television show and display an appropriate error message if the desired show is not available. Save the file as JTVDownload2.java. For program b save JTVDowload as JTVDownload2, the programs are the same except for the changes and added code to allow for user input *******************************

I was able to figure out part a :

import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class JTVDownload extends JFrame implements ItemListener { JComboBox programBox = new JComboBox(); JLabel programList = new JLabel("*** Program List ***"); JLabel stars = new JLabel("*****************************"); JTextField descripField = new JTextField(20); // add your desired TV programs to the string String[] progs = {"The Walking Dead","Gotham","9-1-1","This is Us","ANTM"}; // add your desired TV programs descrips to the string String[] descrips = {"","Humans living in a zombie apocalypse","Drama series based off Batman","Series about lives of first responders","Emotional drama about a family","Modeling competition"}; public JTVDownload() { super("JTVDownload"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout()); programBox.addItemListener(this); add(stars); add(programList); programBox.addItem("none"); for(int x = 0; x < progs.length; ++x) programBox.addItem(progs[x]); add(programBox); add(descripField); } public static void main(String[] arguments) { JTVDownload frame = new JTVDownload(); frame.setSize(300,150); frame.setVisible(true); } @Override public void itemStateChanged(ItemEvent list) { Object source = list.getSource(); if(source == programBox) { int num = programBox.getSelectedIndex(); descripField.setText(descrips[num]); } } }

but i need help with part b.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions