
como abrir una clase mediante un boton en java netbeans
Publicado por juan antonio (1 intervención) el 02/05/2015 02:17:30
hola amigos soy nuevo en java y recien estoy empezando a entrar en eso de java swing mi pregunta es como puedo ejecutar este codigo al presionar un boton en java netbeans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package cuadradomedias;
/**
*
* @author juancony
*/import java.io.*;
import javax.swing.JOptionPane;
public class Cuadradomedias {public static void main(String arg[])throws IOException
{BufferedReader entrada=new BufferedReader(new InputStreamReader(System.in));
int cantidad,semilla=Integer.parseInt(JOptionPane.showInputDialog(" INTRODUZCA SEMILLA"));;
int tamano1,tamano2,i;
String cadena,new_numero;cadena=String.valueOf(semilla); // conversion de entero a cadena
tamano1=cadena.length(); // tamaño de la cadena
double semilla_cuadrada=0;cantidad=Integer.parseInt(JOptionPane.showInputDialog(" NUMEROS A GENERAR"));
for(i=0; i<cantidad; i++)
{semilla_cuadrada=Math.pow(semilla,2);
new_numero=proceso_seleccion(semilla_cuadrada,tamano1);
Integer entero=new Integer(new_numero);
semilla=entero.intValue();
System.out.println(semilla);
} }static String proceso_seleccion(double recibe_semilla,int tamano1)
{int tamano2,resta,contador=0; int i,posicion=0;
String new_cadena="",cadena;
int semilla=(int)recibe_semilla;
cadena=String.valueOf(semilla); // conversion de entero a cadena
tamano2=cadena.length(); // tamaño de la cadena
resta=(tamano2)-tamano1;
posicion=tamano2%(tamano1+1);
//posicion=tamano2%tamano1;
tamano1++;
if (posicion==0)
{ posicion=tamano2/tamano1;for(i=posicion; ; i++)
{if (contador!=tamano1)
{new_cadena+=cadena.charAt(i);
contador++;
}else
{break;
} } }else
{for(i=posicion-1; ; i++)
{if (contador!=tamano1)
{new_cadena+=cadena.charAt(i);
contador++;
}else
{break;
} } }return new_cadena;
}static int tamano(double semilla)
{int i=0,c=0;
for(i=0; i<20; i++)
{c++;
semilla=semilla/10;if (semilla<10)
{c++;
i=20; } }return c;
}}Valora esta pregunta


0
