import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class CelsiusFarenheit extends JFrame implements ActionListener{ //celsiuas*1.8+32
JPanel miPanel;
JButton miBoton;
JCheckBox miCheckBox;
JTextArea miAreaDeTexto;
JTextField texto;
double valor = 0;
CelsiusFarenheit(){
miPanel = new JPanel();
JPanel panelInferior = new JPanel();
miBoton = new JButton ("Celsius");
miBoton.addActionListener((ActionListener) this);
miAreaDeTexto = new JTextArea("Farenheit");
texto = new JTextField(10);
JTextArea textoCelsius = new JTextArea("Celsius");
miPanel.add(texto);
miPanel.add(textoCelsius);
miPanel.add(panelInferior);
panelInferior.add(miBoton);
panelInferior.add(miAreaDeTexto);
// panelInferior.add(texto);
this.add(miPanel);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
CelsiusFarenheit vent = new CelsiusFarenheit();
vent.setTitle("Ventana");
vent.setSize(300,200);
vent.setDefaultCloseOperation(EXIT_ON_CLOSE);
vent.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==miBoton){
double calculo=((Integer.parseInt(texto.getText()))*1.8)+32;
miAreaDeTexto.setText(calculo +" farenheit");
}
}
}
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class CelsiusFarenheit extends JFrame implements ActionListener{ //celsiuas*1.8+32
JPanel miPanel;
JButton miBoton;
JCheckBox miCheckBox;
JTextArea miAreaDeTexto;
JTextField texto;
double valor = 0;
CelsiusFarenheit(){
miPanel = new JPanel();
JPanel panelInferior = new JPanel();
miBoton = new JButton ("Celsius");
miBoton.addActionListener((ActionListener) this);
miAreaDeTexto = new JTextArea("Farenheit");
texto = new JTextField(10);
JTextArea textoCelsius = new JTextArea("Celsius");
miPanel.add(texto);
miPanel.add(textoCelsius);
miPanel.add(panelInferior);
panelInferior.add(miBoton);
panelInferior.add(miAreaDeTexto);
// panelInferior.add(texto);
this.add(miPanel);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
CelsiusFarenheit vent = new CelsiusFarenheit();
vent.setTitle("Ventana");
vent.setSize(300,200);
vent.setDefaultCloseOperation(EXIT_ON_CLOSE);
vent.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==miBoton){
double calculo=((Integer.parseInt(texto.getText()))*1.8)+32;
miAreaDeTexto.setText(calculo +" farenheit");
}
}
}