How to change the code so that it extends Application instead of the JFrame?
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; import java.util.ArrayList; public class Races extends JFrame{ private JPanel jpCenter = new JPanel(); private boolean keepGoing = true; private ArrayList threadList = new ArrayList<>(); public static void main(String[] args){ int num = 0; try{ num = Integer.parseInt(args[2]); } catch(Exception e){ num = 5; } new Races(num); } public Races(int num){ this.setTitle("Off to the Races"); this.setSize(500, 50 * (num + 2)); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); for(int i = 0; i < num; i++){ RaceThread racer = new RaceThread(i + 1, i * 32); this.add(racer); Thread t = new Thread(racer); threadList.add(t); } this.setVisible(true); for(int i = 0; i < threadList.size(); i++){ threadList.get(i).start(); } } public void paintComponent(Graphics g){ g.setColor(Color.black); g.drawLine(450,0, 450, 1000); } class RaceThread extends JPanel implements Runnable{ private JLabel label; private JProgressBar progress; private String name; private Icon pic = null; private int x = 0; private int y = 0; private JLabel picLabel; public RaceThread(int num, int yPos){ this.name = "" + num; this.y = yPos; pic = new ImageIcon("races.png"); picLabel = new JLabel("", pic, JLabel.CENTER); } public void paintComponent(Graphics g){ super.paintComponent(g); pic.paintIcon(this, g, x, y); if(keepGoing == false){ g.drawString("Winner is: " + name, 0, y); revalidate(); } } public void run(){ try{ Thread.sleep(1000); } catch(InterruptedException ie){ System.out.println("Error: " + ie); } for(int i = 1; (i <= 180) && (keepGoing == true); i++){ x += 0 + (int)(Math.random() * ((5 - 0) + 1)); this.repaint(); try{ Thread.sleep((int)(Math.random() * 100)); } catch(InterruptedException ie){ System.out.println("Error: " + ie); } } keepGoing = false; this.repaint(); revalidate(); } } }