home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.awt.TextField;
- import java.awt.event.ItemEvent;
- import java.awt.event.MouseEvent;
-
- public class degrees extends Applet {
- boolean FSelected;
- TextField edit1;
- Checkbox Fahrenheit;
- CheckboxGroup group1;
- Button clearbutton;
- Checkbox Celcius;
-
- public void init() {
- GridBagLayout gridBagLayout = new GridBagLayout();
- ((Container)this).setLayout(gridBagLayout);
- ((Component)this).setSize(226, 95);
- this.edit1 = new TextField(15);
- this.edit1.setBounds(33, 24, 24, 23);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = (double)1.0F;
- gbc.weighty = (double)1.0F;
- gbc.anchor = 15;
- gbc.fill = 0;
- gbc.insets = new Insets(0, 0, 0, 0);
- ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.edit1, gbc);
- ((Container)this).add(this.edit1);
- this.group1 = new CheckboxGroup();
- this.Fahrenheit = new Checkbox("Fahrenheit", this.group1, true);
- this.Fahrenheit.setBounds(90, 24, 89, 23);
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 0;
- gbc.weightx = (double)1.0F;
- gbc.weighty = (double)1.0F;
- gbc.anchor = 16;
- gbc.fill = 0;
- gbc.insets = new Insets(0, 0, 0, 0);
- ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.Fahrenheit, gbc);
- ((Container)this).add(this.Fahrenheit);
- this.clearbutton = new Button();
- this.clearbutton.setActionCommand("button");
- this.clearbutton.setLabel("Clear");
- this.clearbutton.setBounds(23, 59, 44, 23);
- this.clearbutton.setBackground(new Color(8421504));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = (double)1.0F;
- gbc.weighty = (double)1.0F;
- gbc.fill = 0;
- gbc.insets = new Insets(0, 0, 0, 0);
- ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.clearbutton, gbc);
- ((Container)this).add(this.clearbutton);
- this.Celcius = new Checkbox("Celcius", this.group1, false);
- this.Celcius.setBounds(90, 47, 72, 23);
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 1;
- gbc.weightx = (double)1.0F;
- gbc.weighty = (double)1.0F;
- gbc.anchor = 18;
- gbc.fill = 0;
- gbc.insets = new Insets(0, 0, 0, 0);
- ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.Celcius, gbc);
- ((Container)this).add(this.Celcius);
- this.FSelected = true;
- this.edit1.requestFocus();
- degrees$SymItem lSymItem = new degrees$SymItem(this);
- this.Celcius.addItemListener(lSymItem);
- this.Fahrenheit.addItemListener(lSymItem);
- degrees$SymMouse lSymMouse = new degrees$SymMouse(this);
- this.clearbutton.addMouseListener(lSymMouse);
- ((Container)this).validate();
- }
-
- void clickedFahrenheit(ItemEvent event) {
- if (!this.FSelected) {
- float degree;
- try {
- degree = Float.valueOf(this.edit1.getText());
- } catch (NumberFormatException var3) {
- return;
- }
-
- if (degree <= 0.0F) {
- this.edit1.setBackground(Color.blue);
- } else if (degree >= 100.0F) {
- this.edit1.setBackground(Color.red);
- } else {
- this.edit1.setBackground(Color.white);
- }
-
- this.edit1.setText(String.valueOf(1.8 * (double)degree + (double)32.0F));
- this.FSelected = true;
- }
- }
-
- void clickedCelcius(ItemEvent event) {
- if (this.FSelected) {
- float degree;
- try {
- degree = Float.valueOf(this.edit1.getText());
- } catch (NumberFormatException var3) {
- return;
- }
-
- if (degree <= 32.0F) {
- this.edit1.setBackground(Color.blue);
- } else if (degree >= 212.0F) {
- this.edit1.setBackground(Color.red);
- } else {
- this.edit1.setBackground(Color.white);
- }
-
- this.edit1.setText(String.valueOf(((double)degree - (double)32.0F) / 1.8));
- this.FSelected = false;
- }
- }
-
- void clearbutton_MouseClick(MouseEvent event) {
- this.edit1.setText("");
- this.edit1.setBackground(Color.white);
- }
- }
-