At this time, some platforms--notably Linux and the Macintosh--do not yet have a stable platform for Java 2 programming. For that reason, I supply a compatibility package that enables students to compile the programs in Computing Concepts with Java 2 Essentials with a Java 1.1 compatible compiler. (Note: Java 1.0 is not supported. Note further that Microsoft J++ 1.1 implements Java 1.0 only.)
To use the compatibility package, students must take the following steps.
(Don't have ZIP on your platform? Just use jar: jar xvf java2compatibility.zip)
import com.horstmann.ccj.java2compatibility.ClassName;for Java 2 classes such as Graphics2D, JFrame, and so on. See below for a complete list.
Graphics2D g2 = (Graphics2D)g;to a constructor call
Graphics2D g2 = new Graphics2D(g);This is unfortunately unavoidable since Java 1.1 doesn't supply a Graphics2D object when calling paint.
|Class||Change from Java 2||to Java 1.1|
|Math||Math.toRadians(x)||x * Math.PI / 180|
|Random||r.nextInt(n)||r.nextInt() % n|
The following classes and interfaces are supported:
Graphics2D FontRenderContext TextLayout RectangularShape Ellipse2D.Double Rectangle2D.Double Point2D.Double Line2D.Double JFrame JPanel JButton JTextField JTextArea JMenuBar JMenu JMenuItem JCheckBox JRadioButton JComboBox JOptionPane JFileChooser
Note: If your environment supports Java 1.1 with Swing, then you only need the first few graphics classes from the Java 2 support package. In that case, tell your students to keep the javax.swing classes and place the Swing library on the class path.