package class7_3_RemoteControl_inClass; import javax.swing.*; import java.awt.*; /** * This class controls the operation of an automobile * @author hornick */ public class Car extends JFrame { JLabel status = new JLabel(); public Car(String title) { setTitle(title); setSize(200, 80); setLocation(100, 100); setResizable(false); setVisible(true); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // Retrieves the window's contentPane and sets the background color Container contentPane = getContentPane(); JPanel jp = new JPanel(); contentPane.add(jp); jp.setBackground(Color.LIGHT_GRAY); status.setText("engine off"); jp.add(status); contentPane.validate(); contentPane.repaint(); } /** * Simulate the command that starts the engine */ public void startEngine() { status.setText("engine on"); } /** * Simulate the command that shuts the engine off */ public void stopEngine() { status.setText("engine off"); } // Any number of other commands may be implemented here }