// MatrixStarter.java // Class that allows the program to run under an applet. import java.awt.*; import java.awt.event.*; import java.applet.*; public class MatrixStarter extends Applet implements ActionListener { private Button start = new Button("Start Matrix Chain Multiplier"); private MatrixApp ma = null; public void init() { start.setBackground(SystemColor.control); setBGColor(getParameter("background")); setLayout(new FlowLayout()); add(start); start.addActionListener(this); } public void close() { ma.setVisible(false); ma.dispose(); ma = null; } public void actionPerformed(ActionEvent ae) { if (ae.getSource() == start) if (ma == null) ma = new MatrixApp(this, true); else ma.toFront(); } private void setBGColor(String background) { if ((background == null) || (background.length() != 7) || (background.charAt(0) != '#')) setBackground(Color.white); else { String hexcolor, red, green, blue; hexcolor = background.substring(1, background.length()); red = hexcolor.substring(0, 2); green = hexcolor.substring(2, 4); blue = hexcolor.substring(4, 6); setBackground(new Color(Integer.parseInt(red, 16), Integer.parseInt(green, 16), Integer.parseInt(blue, 16))); } } }