Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   JAVA (https://www.clubdelphi.com/foros/forumdisplay.php?f=16)
-   -   Applet y clases (https://www.clubdelphi.com/foros/showthread.php?t=51301)

nemesis 11-12-2007 23:20:48

Applet y clases
 
Estoy casi terminando este applet pero no se como hacer los calculos uzando en un applet utilizando Clases :confused: lo pudiera hacer de una forma facil pero la profe quiere que usemos 2 clases y escogi hacer el projecto en applet.

aqui esta el codigo de el applet casi ya terminado
Código:

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;


public class Applet1 extends Applet implements ActionListener
{
   
    public void init()
    {
        initForm();
    }


    Label Title = new Label();
    JTextField txtData;
    Button FtoI = new Button("Feet to Inches");
    Button PtoK = new Button("Pounds to Kilograms");
   
    void initForm()
    {
        this.setLayout(null);
        this.setBackground(Color.black);
        this.setForeground(Color.red);
        this.add(Title);
        Title.setText("Metric Unit Converter");
        Title.setFont(new Font("Arial", Font.BOLD, 16));
        Title.setBounds(120, 0, 200, 20);
        txtData = new JTextField();
        txtData.setBounds(135,60,130,20);
        this.add(txtData);
        this.add(FtoI);
        FtoI.setBounds(140, 100, 120, 30);
        FtoI.addActionListener(this);
        this.add(PtoK);
        PtoK.setBounds(140, 150, 120, 30);
        PtoK.addActionListener(this);
    }

   
    public void actionPerformed(ActionEvent evt)
    {
        double data = Double.parseDouble(txtData.getText());
       
        if(evt.getActionCommand().equals("Feet to Inches"))
        {
            ;
        }
           
        else if(evt.getActionCommand().equals("Pounds to Kilograms"))
        {
            ;
        }   
    }
       
}


y una de las clases que voy a utilizar

Código:

public class convertidor
{
    private double valor_pulgadas;
   
    convertidor()
    {
        valor_pulgadas = 0;
    }
   
    convertidor(double data)
    {
        valor_pulgadas = data;
    }
   
    public double Valor()
    {
        return valor_pulgadas * 12;
    }
 
    public void Setpulgadas(double data)
    {
        valor_pulgadas = data;   
    }
 
    public double Getpulgadas()
    {
        return valor_pulgadas;
    }
}



La franja horaria es GMT +2. Ahora son las 12:20:45.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi