/*
* 1.1+Swing version.
*/
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class _89 {
_113 _90, _91;
_16[] _92 = new _16[3];
_16[] _93 = new _16[4];
final static boolean _94 = false;
final static boolean _95 = false;
final static String _96 = null;
_32 _97 = new _32();
JPanel _98;
/**
* Create the ConversionPanels (one for metric, another for U.S.).
* I used "U.S." because although Imperial and U.S. distance
* measurements are the same, this program could be extended to
* include volume measurements, which aren't the same.
*
* Put the ConversionPanels into a frame, and bring up the frame.
*/
public _89() {
//Create Unit objects for metric distances, and then
//instantiate a ConversionPanel with these Units.
_92[0] = new _16("Centimeters", 0.01);
_92[1] = new _16("Meters", 1.0);
_92[2] = new _16("Kilometers", 1000.0);
_90 = new _113(this, "Metric System", _92, _97);
//Create Unit objects for U.S. distances, and then
//instantiate a ConversionPanel with these Units.
_93[0] = new _16("Inches", 0.0254);
_93[1] = new _16("Feet", 0.305);
_93[2] = new _16("Yards", 0.914);
_93[3] = new _16("Miles", 1613.0);
_91 = new _113(this, "U.S. System", _93,
new _0(_97));
//Create a JPanel, and add the ConversionPanels to it.
_98 = new JPanel();
if (_94) {
_98.setBackground(Color.red);
}
_98.setLayout(new GridLayout(2, 1, 5, 5));
_98.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
_98.add(_90);
_98.add(_91);
_99(true);
}
public void _99(boolean _100) {
double _101 = _90._135();
double _102 = _91._135();
int _103 = _113._123;
if (_101 > _102) {
_103 = (int)(_113._123 *
(_102 / _101));
}
if (_95) {
System.out.println("in Converter resetMaxValues");
System.out.println(" metricMultiplier = "
+ _101
+ "; usaMultiplier = "
+ _102
+ "; maximum = "
+ _103);
}
_97.setMaximum(_103);
if (_100) {
_97._49(_103);
}
}
private static void _104() {
String _105 = null;
if (_96 != null) {
if (_96.equals("Metal")) {
_105 = UIManager.getCrossPlatformLookAndFeelClassName();
} else if (_96.equals("System")) {
_105 = UIManager.getSystemLookAndFeelClassName();
} else if (_96.equals("Mac")) {
_105 = "com.sun.java.swing.plaf.mac.MacLookAndFeel";
//PENDING: check!
} else if (_96.equals("Windows")) {
_105 = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else if (_96.equals("Motif")) {
_105 = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}
if (_95) {
System.out.println("About to request look and feel: "
+ _105);
}
try {
UIManager.setLookAndFeel(_105);
} catch (ClassNotFoundException _106) {
System.err.println("Couldn't find class for specified look and feel:"
+ _105);
System.err.println("Did you include the L&F library in the class path?");
System.err.println("Using the default look and feel.");
} catch (UnsupportedLookAndFeelException _107) {
System.err.println("Can't use the specified look and feel ("
+ _105
+ ") on this platform.");
System.err.println("Using the default look and feel.");
} catch (Exception _108) {
System.err.println("Couldn't get specified look and feel ("
+ _105
+ "), for some reason.");
System.err.println("Using the default look and feel.");
_108.printStackTrace();
}
}
}
public static void main(String[] _109) {
_104();
_89 _110 = new _89();
//Create a new window.
JFrame _111 = new JFrame("Converter");
_111.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent _112) {
System.exit(0);
}
});
//Add the JPanel to the window and display the window.
//We can use a JPanel for the content pane because
//JPanel is opaque.
_111.setContentPane(_110._98);
if (_94) {
//This has no effect, since the JPanel completely
//covers the content pane.
_111.getContentPane().setBackground(Color.green);
}
_111.pack(); //Resizes the window to its natural size.
_111.setVisible(true);
}
}