Ciclo

"Ciclo (cubo de numero)"


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


@SuppressWarnings("serial")
public class cubo extends JFrame implements ActionListener {
private JButton boton;
private JTextField campotexto;

    public static void main(String[] args) {
  cubo demo=new cubo();
demo.setSize(250,120);
demo.setTitle("Ciclo");
demo.crearGUI();
demo.setVisible(true); }

    private void crearGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        Container ventana=getContentPane();
        ventana.setLayout(new FlowLayout());
        boton=new JButton("empezar");
        ventana.add(boton);
        boton.addActionListener(this);
        campotexto=new JTextField(20);
        ventana.add(campotexto);
        campotexto.setText("1,2,3,4,5,6,7,8,9,10"); }

    @Override
    public void actionPerformed(ActionEvent event) {
        int numero;
        String unoaldiez="";
        numero=1;
        while(numero<=10) {unoaldiez=unoaldiez + Integer.toString(numero*numero*numero) + ",";
        numero++;
            
        }
    campotexto.setText(unoaldiez);
        }

}

Contacto

EDUARDO LEMB EDUARDO MEDINA BECERRA
3º "C"
"PROGRAMACION ESTRUCTURADA"
5542517616 whats Apps eduardo-m-b@hotmail.com