<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Creations.cl &#187; desarrollo</title>
	<atom:link href="http://www.creations.cl/tag/desarrollo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.creations.cl</link>
	<description>Programación y algo más...</description>
	<lastBuildDate>Sat, 10 Dec 2011 06:50:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Especificaciones</title>
		<link>http://www.creations.cl/2009/11/especificaciones/</link>
		<comments>http://www.creations.cl/2009/11/especificaciones/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 13:13:51 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[computación]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[informática]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=1064</guid>
		<description><![CDATA[Sé que muchos programadores se sentirán identificados con esta carta.
¿Qué pasaría si en vez de programadores fueramos arquitectos?, unos dirán que sólo es el cambio de carrera, pero ¿y si ahora le agregamos que los jefes nos explican el problema y sus requerimientos de la misma en como la informan a los programadores?
Estimado Sr. Arquitecto:
Por [...]]]></description>
			<content:encoded><![CDATA[<p>Sé que muchos programadores se sentirán identificados con esta carta.</p>
<p>¿Qué pasaría si en vez de programadores fueramos arquitectos?, unos dirán que sólo es el cambio de carrera, pero ¿y si ahora le agregamos que los jefes nos explican el problema y sus requerimientos de la misma en como la informan a los programadores?</p>
<p><em><strong>Estimado Sr. Arquitecto:</strong></em><br />
Por favor diseñe y construya una casa para mi. No estoy muy seguro de lo que necesito, así que tendrá que usar su imaginación. Mi casa debería tener entre dos y cuarenta y cinco dormitorios. Simplemente asegúrese de que todo esté pensado de forma que sea sencillo añadir o quitar dormitorios. Cuando<br />
me traiga los modelos, tomaré la decisión sobre lo que quiero. Además, tráigame un resumen de los costes para cada configuración de manera que pueda elegir una de ellas de manera arbitraria.<br />
Tenga en cuenta que la nueva casa debe costar bastante menos que la casa en la que estoy viviendo ahora. Pero asegúrese, de todas formas, de que corrige todas las deficiencias que existen en mi casa actual (el suelo de la cocina vibra cuando ando por el, y las paredes no tienen suficiente aislamiento).<br />
Mientras diseña, tenga en cuenta que quiero mantener los costes de mantenimiento lo mas bajos posibles. Esto significará la incorporación de materiales mas costosos coste como el aluminio, la fibra de vidrio o el vinilo. (Si elige no considerar el aluminio, prepárese para explicar su decisión en todo detalle.)<br />
Por favor asegúrese de que se utilicen las prácticas mas modernas de diseño y lo último de lo último en materiales a la hora de construir la casa, ya que deseo poder presumir de haber utilizado las mas actuales ideas y métodos. Tenga en cuenta, de todas formas, que la cocina debería diseñarse para acomodar, entre otras cosas, mi nevera Gibson del 52.<br />
Para asegurarse de que esté construyendo la casa de manera correcta para toda la familia, contacte con cada uno de mis hijos e hijas, y también con mis nueros y nueras. Mi suegra tendrá también bastantes cosas que decir sobre como debería diseñarse la casa, ya que nos visita al menos una vez al<br />
año. Asegúrese de que considera cada una de las opciones que le propongan cuidadosamente y asegúrese también de elegir la decisión acertada. Yo, de cualquier forma, siempre tendré la última palabra y podré rectificar cualquier elección que tome.<br />
Por favor no me moleste con los pequeños detalles de momento. Su trabajo es desarrollar una idea general del diseño de la casa: captar la idea. Este momento, por ejemplo, no es el apropiado para elegir el color de la alfombra.<br />
En cualquier caso, recuerde que a mi esposa le gusta el azul.<br />
Además, no se preocupe aún de adquirir los materiales necesarios para construir la casa. Su prioridad es la de desarrollar planos detallados y especificaciones. De todas formas, una vez que yo apruebe esos planos, espero que la casa esté construida en 48 horas.<br />
Aunque esté diseñando esta casa específicamente para mí, tenga en cuenta que antes o después tendré que venderla a otra persona. De manera que debería ser atrayente para una gran variedad de compradores potenciales. Por favor<br />
asegúrese antes de que finalice los planos de que halla un consenso sobre las características de la casa entre la población de la zona. Le aconsejo que eche un vistazo a la casa que mi vecino se construyó el año pasado. Nos encanta. Tiene bastantes características que también queremos en nuestra nueva casa, especialmente la piscina de 75 pies. Aplicando la ingeniería de<br />
manera cuidadosa, creo que no tendrá dificultades en añadirlo al diseño final sin que tenga ningún impacto en el coste.<br />
Por favor prepare un conjunto completo de modelos. No es necesario por ahora que prepare el diseño real, dado que solo queremos los modelos para calcular los costes de la obra. Tenga en cuenta, de todas formas, que usted será el responsable de cualquier incremento en el precio debido a cambios posteriores en el diseño.<br />
¡Debería estar emocionado por trabajar en un proyecto tan interesante como este! Poder utilizar las últimas técnicas y materiales y el que le den tanta libertad en sus diseños es algo que no ocurre muy a menudo. Contacte conmigo tan pronto como sea posible con una lista completa de sus ideas y sus planes.</p>
<p>*Postdata:* Mi esposa acaba de decirme que no está de acuerdo con algunas de las instrucciones que le doy en esta carta. Como arquitecto, es su responsabilidad el resolver estas diferencias entre mi esposa y yo. Yo ya lo he intentado en el pasado y fui incapaz de conseguirlo. Si no puede hacer frente a esta responsabilidad, tendré que contratar a otro arquitecto.</p>
<p>*PostPostdata:* Quizás lo que necesite ni tan si quiera sea una casa, sino una caravana. Por favor aconséjeme lo mas pronto posible si ese es el caso..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/11/especificaciones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La Biblia del programador</title>
		<link>http://www.creations.cl/2009/05/la-biblia-del-programador/</link>
		<comments>http://www.creations.cl/2009/05/la-biblia-del-programador/#comments</comments>
		<pubDate>Fri, 08 May 2009 17:45:32 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[computación]]></category>
		<category><![CDATA[bilbia del programador]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[Dios programador]]></category>
		<category><![CDATA[genesis]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=914</guid>
		<description><![CDATA[

1. Al principio Dios creo el Bit y el Byte. Y de ellos creo la Palabra.
2. Y hubo dos bytes en una palabra; y nada mas existía. Y Dios separo el Uno del Cero; y vio que esto era bueno.
3. Y Dios dijo:
- Hágase el Dato.
Y así sucedió.
Y Dios dijo:
- Que los Datos vayan a [...]]]></description>
			<content:encoded><![CDATA[<div class="MultiBoxHelp" id="MultiBoxHelp"><a href="http://www.rutschmann.biz" title="powered by Wordpress Multibox Plugin v1.3.5" target="_blank"><img src="http://www.creations.cl/wp-content/plugins/wordpress-multibox-plugin/images/help.png" alt="powered by Wordpress Multibox Plugin v1.3.5" title="powered by Wordpress Multibox Plugin v1.3.5"></a></div>
<p><a href="http://www.creations.cl/wp-content/uploads/2009/05/genesis.jpg"  class="wmp" id="wmp2"><img class="aligncenter size-full wp-image-915" title="genesis" src="http://www.creations.cl/wp-content/uploads/2009/05/genesis.jpg" alt="genesis" width="525" height="400" /></a></p>
<p>1. Al principio Dios creo el Bit y el Byte. Y de ellos creo la Palabra.</p>
<p>2. Y hubo dos bytes en una palabra; y nada mas existía. Y Dios separo el Uno del Cero; y vio que esto era bueno.</p>
<p>3. Y Dios dijo:<br />
- Hágase el Dato.<br />
Y así sucedió.<br />
Y Dios dijo:<br />
- Que los Datos vayan a su correspondiente lugar.<br />
Y creo los disquetes, discos duros y los compactos.</p>
<p>4. Y dijo Dios<br />
- Háganse los computadores, así habrá lugar para poner los disquetes, discos duros y compactos.<br />
Y Dios creo los computadores y los llamó Hardware.</p>
<p>5. Y no había Software aun.<br />
Pero Dios creo programas, chicos y grandes&#8230;<br />
Y les dijo:<br />
- Vayan y multiplíquense por si mismos y llenen toda la Memoria.</p>
<p>6. Y dijo Dios:<br />
- Creare al Programador; y el Programador hará nuevos programas y gobernara sobre los computadores, programas y datos.</p>
<p>7. Y Dios creo al Programador y lo puso en el Centro de Datos.<br />
Y Dios le mostró al Programador el Árbol de Directorios y le dijo:<br />
- Puedes usar todos los volúmenes y subvolumenes, pero NO USES Windows.</p>
<p>8. Y Dios dijo:<br />
- No es bueno para el Programador estar solo.<br />
Y tomo un hueso del cuerpo del Programador y creo una criatura que buscaría al Programador, lo admiraría y amaría las cosas que hiciera el Programador;<br />
Y Dios llamo a la criatura EL USUARIO.</p>
<p>9. Y el Programador y el Usuario fueron dejados por EL solos bajo el DOS desnudo y fue bueno.</p>
<p>10. Pero Bill fue mas listo que todas las otras criaturas de Dios.<br />
Y Bill le dijo al Usuario:<br />
- ¿Realmente Dios te dijo que no ejecutaras ningún programa?<br />
11. Y respondió el Usuario<br />
- Dios nos dijo que podíamos usar cualquier programa y cualquier dato pero nos dijo que no ejecutáramos Windows o moriríamos.</p>
<p>12. Y Bill dijo al Usuario<br />
- ¿Cómo puedes hablar sobre algo que no has probado? En el momento que corras Windows te convertirás en igual a Dios. Podrás crear cualquier cosa que desees con un simple clic del ratón?</p>
<p>13. Y el Usuario vio que los frutos del Windows eran buenos y fáciles de usar. Y el Usuario vio que cualquier conocimiento era inútil, pues Windows podía reemplazarlos.</p>
<p>14. Así que el Usuario instalo Windows en su computador y le dijo al Programador que era bueno.</p>
<p>15. Y el Programador empezó a buscar nuevos drivers.<br />
Y Dios le pregunto:<br />
- ¿Qué buscas?<br />
Y el Programador respondió:<br />
- Busco nuevos drivers porque no puedo hallarlos en el DOS.<br />
Y Dios dijo:<br />
- ¿Quien te dijo que necesitabas drivers? ¿Ejecutaste Windows?<br />
Y el Programador dijo:<br />
- ¡Fue Bill quien nos lo dijo!</p>
<p>16. Y Dios dijo a Bill:<br />
- Por lo que hiciste serás odiado por todas las criaturas.<br />
Y el Usuario estará siempre descontento contigo.<br />
Y siempre venderás Windows.<br />
17. Y Dios dijo al Usuario<br />
- Por lo que hiciste Windows te decepcionara y se comerá todos tus recursos.<br />
Y tendrás que usar programas piojosos.<br />
Y siempre confiaras en la ayuda del Programador.</p>
<p>18. Y Dios dijo al Programador:<br />
- Porque oíste al Usuario nunca serás feliz. Todos tus programas tendrán errores y tendrás que arreglarlos hasta el fin de los tiempos.</p>
<p>19. Y Dios los echo del Centro de Datos y cerro la puerta y la aseguró con un password.</p>
<p>20. FALLA DE PROTECCION GENERAL &#8211; Apriete Ctrl-Alt-Del</p>
<p>Fuente: Demasiadas,  no se cuál es la original.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/05/la-biblia-del-programador/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Errores comunes al programar en JAVA</title>
		<link>http://www.creations.cl/2009/03/errores-comunes-al-programar-en-java/</link>
		<comments>http://www.creations.cl/2009/03/errores-comunes-al-programar-en-java/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 21:20:07 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[j2ee]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=746</guid>
		<description><![CDATA[Si ha estado trabajando con Java por algún tiempo, es seguro que habrá cometido estos errores al menos un par de veces. Los errores de programación en Java, así como en otros lenguajes, ocurren más que todo en la sintaxis y errores en la lógica. Los errores en la sintaxis son causados cuando el compilar [...]]]></description>
			<content:encoded><![CDATA[<p>Si ha estado trabajando con Java por algún tiempo, es seguro que habrá cometido estos errores al menos un par de veces. Los errores de programación en Java, así como en otros lenguajes, ocurren más que todo en la sintaxis y errores en la lógica. Los errores en la sintaxis son causados cuando el compilar Java (javac) no puede reconocer la sentencia. Esto causa que el compilador devuelva un mensaje de error, usualmente con una línea de código de referencia. También se conoce a los errores de sintaxis como errores en tiempo de compilación.</p>
<p>Los errores de lógica son conocidos como BUGS. Estos son los errores que nos tomarán tiempo hasta encontrarlos. Si damos a elegir, cualquier programador elegiría los errores en tiempo de compilación. A mi me ha tomado hasta varios días hacer el debug cuando suceden errores de lógica, y eso, usando todas las herramientas disponibles: archivos logs, mensajes System.out, debuggers, etc.</p>
<p>Los siguientes errores aparecen en la mayoría de programadores cada cierto tiempo, pero podemos verlo regularmente en el código de los programadores novatos.</p>
<p>Tenemos que cuidarnos de estos errores para evitarlos y pulir nuestro código.</p>
<ul>
<li><strong>El nombre de la Clase pública no coincide con el nombre del archivo</strong><br />
Cada archivo .java puede contener sólo una Clase pública. El nombre de esa Clase pública debe coincidir exactamente con el nombre del archivo antes de la extensión .java, respetando incluso las mayúsculas y minúsculas. Por ejemplo, una Clase pública llamada MyClass debe estar en un archivo MyClass.java y no en myclass.java. Este es un error de sintaxis.</li>
<li><strong>Una Clase no está en el directorio correcto</strong><br />
Este error de sintaxis ocurre si el comando javac no puede encontrar un archivo .java en el directorio esperado. Si una Clase está en el paquete por defecto (no tiene la declaración del package en la primera línea), entonces esta Clase pertenece al directorio actual de trabajo o al directorio donde apunta el flag sourcepath del javac. Si una Clase está a un paquete, entonces pertenece a un subdirectorio debajo del directorio actual de trabajo o a un subdirectorio debajo del directorio donde apunta el flan sourcepath del javac. Por ejemplo, si existe una Clase llamada com.hello.HelloWorld entonces su nombre es HelloWorld y su paquete es com.hello. Si el flan sourcepath está configurada a c:src, entonces el archivo HelloWorld.java debe estar ubicado en el subdirectorio: c:srccomhello.</li>
<li><strong>Usando equals contra la asignación ( == versus = )</strong><br />
En Java este error puede ser incluso un error de lógica o sintaxis. Para comparar 2 referencias para igualarlas se usa el operador == (el operador de igualdad). Para asignar el valor de la derecha a la variable de la izquierda se usa el operador = (operador de asignación). Los programadores novatos a veces escriben: if (miValor = valorEsperado) Este código intenta evaluar el valorEsperado como un valor booleano en lugar de intentar la evaluación de igualdad entre miValor y valorEsperado. Si valorEsperado es del tipo booleano, entonces el código tendrá un error de lógica y probará si el valorEsperado es verdadero o falso. Si valorEsperado no es del tipo booleano, entonces el código lanzará un error de compilación debido a que la estructura if requiere un valor booleano que sea retornado de la comparación (miValor = valorEsperado), pero en Java el operador = siempre retorna el valor de la derecha.</li>
<li><strong>Error en mayúsculas y minúsculas.</strong><br />
Java es un lenguaje case sensitive, esto es que debemos respetar las mayúsculas y minúsculas. (miVar no es igual a mivar). Si hacemos referencia a un identificador que no está bien escrito entonces obtendremos un error de sintaxis.</li>
<li><strong>Olvidar que los índices en Java empiezan en 0.</strong><br />
Los índices de los arreglos de Java y las listas empiezan en 0, myArray[0], o myList.get(0). Asegurarse que su loop for no cause errores por este motivo. Si hacemos más loops de los que son posibles, entonces obtendremos el error: ArrayIndexOutBounds exception. Si hacemos menos loops de los requeridos, entonces tendremos un error de lógica.</li>
<li><strong>NullPointerException</strong><br />
El NullPointerException, la maldición de los programadores en Java. Los NullPointerExceptions son errores de lógica causados cuando un programa intenta acceder a métodos o atributos en una referencia que está nula. Si nuestro objeto no ha sido inicializado o ha sido establecido a null con el operador =, entonces la llamada el método o el acceso a uno de sus atributos no es válido.</li>
</ul>
<p>Espero que esta lista corta de errores de código le ayude a pensar de manera defensiva a la hora de escribir código. Mientras más errores evitemos, entonces más productivos seremos, tanto en tiempo de desarrollo como también el código más refinado.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/03/errores-comunes-al-programar-en-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Domingo en la mañana, starbucks Santiago-Chile</title>
		<link>http://www.creations.cl/2009/03/domingo-en-la-manana-starbucks-santiago-chile/</link>
		<comments>http://www.creations.cl/2009/03/domingo-en-la-manana-starbucks-santiago-chile/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 21:00:34 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Anuncios]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Tecnología]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[domingo en la mañana]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=684</guid>
		<description><![CDATA[Difundiendo este gran evento que reune a gente ligada a la web sin importar el tema o motivo.
Fuente: pulsoSocial


Este domingo 8 de Marzo se llevara acabo Domingo en la Mañana en Santigo de Chile en el Starbucks que queda en Calle San Sebastian, 2946, Las Condes, empezando a las 10:30 am.
Que es Domingo en la Mañana?
Es [...]]]></description>
			<content:encoded><![CDATA[<p>Difundiendo este gran evento que reune a gente ligada a la web sin importar el tema o motivo.</p>
<p>Fuente: <a href="http://pulsosocial.com/2009/03/04/domingo-en-la-manana-en-santigo-chile/">pulsoSocial</a></p>
<div class="MultiBoxHelp" id="MultiBoxHelp"><a href="http://www.rutschmann.biz" title="powered by Wordpress Multibox Plugin v1.3.5" target="_blank"><img src="http://www.creations.cl/wp-content/plugins/wordpress-multibox-plugin/images/help.png" alt="powered by Wordpress Multibox Plugin v1.3.5" title="powered by Wordpress Multibox Plugin v1.3.5"></a></div>
<p><a href="http://www.creations.cl/wp-content/uploads/2009/03/starbucks.jpg"  class="wmp" id="wmp4"><img class="alignright size-full wp-image-685" style="border: 1px solid black; padding: 2px; background-color: #AAD;" title="starbucks" src="http://www.creations.cl/wp-content/uploads/2009/03/starbucks.jpg" alt="domingo en la mañana santiago de chile" width="90" height="90" /></a><br />
Este domingo 8 de Marzo se llevara acabo <strong>Domingo en la Mañana en Santigo de Chile</strong> en el <strong>Starbucks</strong> que queda en Calle San Sebastian, 2946, Las Condes, empezando a las 10:30 am.</p>
<h4>Que es Domingo en la Mañana?</h4>
<p>Es como una <em>mini-uncoference</em> muy casual donde emprendedores, developers, diseñadores, bloggers, y en general profesionales de la web se reunen a compartir sus proyectos y sus ideas.</p>
<h4>DELM en Santiago</h4>
<p>Después de que se llevara acabo DELM en Mexico, Bogota, Medellin y Sincelejo, Lina Ceballos publico un articulo invitandonos a hacer un DELM en nuestra ciudad, y no mucho tiempo después, Maria del Carmen hizo un DELM en Quito, y Daniel Falcón nos conto como fue el DELM en Lima.  Bueno, entonces ahora me toca a mi en Santiago <img class="wp-smiley" src="http://pulsosocial.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" /></p>
<p>En el poco tempo que he llevado en Santiago, me he dado cuenta que la comunidad web es grande y bien establecida, y mientras en otras ciudades como Quito y Medellín el DELM es como una semilla para crear una comunidad web, creo que en Santiago DELM servirá como un foro para compartir ideas y proyectos de una manera mucho mas casual que por ejemplo First Tuesday (al cual asistí anoche, que por si es un evento impresionante, pero eso lo dejare para otro articulo.)</p>
<h4>Pero porque un Domingo?</h4>
<p>La primera vez que escuche de el concepto de<strong> Sunday Morning</strong> o <strong>Domingo en la Mañana</strong> lo primero que pensé fue, pero quien se va a levantar un domingo en la mañana a ir a una cosa de estas? Yo ya había participado en BarCamps, WordCamps, RefreshMiami, South Florinda Interactive Marketing Assoc., BlogOrlando y otros eventos relacionados que son de el mismo estilo, pero nunca un Domingo.  Es mas, primero me pareció una pésima idea, pero después caí en cuenta que si se hace un domingo, y en la mañana, solo la gente mas apasionada y mas comprometida con sus proyectos serian los únicos que harían ese pequeño sacrificio. Ese es el tipo gente que de verdad quiero conocer, y los emprendedores que siempre estamos buscando en PulsoSocial.</p>
<p><strong>Información del evento:</strong></p>
<blockquote><p>Fecha: Domingo, Marzo 8, 2009<br />
Hora: 10:30am &#8211; 1:30pm<br />
Ubicación:<br />
Starbucks<br />
Calle San Sebastián, 2946, Las Condes<br />
Santiago, Chile</p>
<p>Confirma tu asistencia en <a href="http://www.facebook.com/event.php?eid=54114146858">Facebook </a></p></blockquote>
<p>El mapa <a href="http://www.creations.cl/wp-content/uploads/2009/03/starbucks.kmz">starbucks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/03/domingo-en-la-manana-starbucks-santiago-chile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>KeyEvent simple en java</title>
		<link>http://www.creations.cl/2009/02/keyevent-simple-en-java/</link>
		<comments>http://www.creations.cl/2009/02/keyevent-simple-en-java/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 18:42:33 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[j2ee]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=634</guid>
		<description><![CDATA[Este código me fué de mucha ayuda cuando recién empecé a ver algo de java en el instituto, espero que le sirva a las nuevas generaciones de programadores.
Acá tenemos un keyListener, su función es captar los eventos del teclado,tanto con o sin modificadores, esto se refiere a si el usuario usa SHIFT o no.
El código [...]]]></description>
			<content:encoded><![CDATA[<p>Este código me fué de mucha ayuda cuando recién empecé a ver algo de java en el instituto, espero que le sirva a las nuevas generaciones de programadores.</p>
<p>Acá tenemos un keyListener, su función es captar los eventos del teclado,tanto con o sin modificadores, esto se refiere a si el usuario usa SHIFT o no.</p>
<p>El código está funcionando, es autónomo, para ejecutar el ejemplo se debe agregar al proyecto a darle RUN.</p>
<div class="igBar"><span id="ljava-2"><a href="#" onclick="javascript:showPlainTxt('java-2'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-2">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package keyListener;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.swing.*;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.awt.event.*;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.awt.BorderLayout;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.awt.Dimension;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> KeyEventDemo <span style="color: #000000; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=allinurl%3AJPanel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JPanel</span></a></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?q=allinurl%3AKeyListener+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyListener</span></a>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AActionListener+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">ActionListener</span></a> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJTextArea+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JTextArea</span></a> displayArea;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJTextField+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JTextField</span></a> typingArea;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> nuevaLinea = <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> KeyEventDemo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">super<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3ABorderLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">BorderLayout</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJButton+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JButton</span></a> button = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJButton+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JButton</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Clear"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button.<span style="color: #006600;">addActionListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">typingArea = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJTextField+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JTextField</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">20</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">typingArea.<span style="color: #006600;">addKeyListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayArea = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJTextArea+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JTextArea</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayArea.<span style="color: #006600;">setEditable</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJScrollPane+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JScrollPane</span></a> scrollPane = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJScrollPane+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JScrollPane</span></a><span style="color: #66cc66;">&#40;</span>displayArea<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">scrollPane.<span style="color: #006600;">setPreferredSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3ADimension+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Dimension</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">375</span>, <span style="color: #cc66cc;color:#800000;">125</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add<span style="color: #66cc66;">&#40;</span>typingArea, <a href="http://www.google.com/search?q=allinurl%3ABorderLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">BorderLayout</span></a>.<span style="color: #006600;">PAGE_START</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add<span style="color: #66cc66;">&#40;</span>scrollPane, <a href="http://www.google.com/search?q=allinurl%3ABorderLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">BorderLayout</span></a>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add<span style="color: #66cc66;">&#40;</span>button, <a href="http://www.google.com/search?q=allinurl%3ABorderLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">BorderLayout</span></a>.<span style="color: #006600;">PAGE_END</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/** Handle the key typed event from the text field. */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> keyTyped<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayInfo<span style="color: #66cc66;">&#40;</span>e, <span style="color: #ff0000;">"KEY TYPED: "</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/** Handle the key pressed event from the text field. */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> keyPressed<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayInfo<span style="color: #66cc66;">&#40;</span>e, <span style="color: #ff0000;">"KEY PRESSED: "</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/** Handle the key released event from the text field. */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> keyReleased<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayInfo<span style="color: #66cc66;">&#40;</span>e, <span style="color: #ff0000;">"KEY RELEASED: "</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/** Handle the button click. */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> actionPerformed<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">ActionEvent</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Limpia los componentes de texto.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayArea.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">typingArea.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Vuelve el foco al área de tipeo.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">typingArea.<span style="color: #006600;">requestFocusInWindow</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> displayInfo<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a> e, <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> s<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> keyString, modString, tmpString,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">actionString, locationString;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> id = e.<span style="color: #006600;">getID</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>id == <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">KEY_TYPED</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">char c = e.<span style="color: #006600;">getKeyChar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">keyString = <span style="color: #ff0000;">"key character = '"</span> + c + <span style="color: #ff0000;">"'"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> keyCode = e.<span style="color: #006600;">getKeyCode</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">keyString = <span style="color: #ff0000;">"key code = "</span> + keyCode</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">" ("</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">getKeyText</span><span style="color: #66cc66;">&#40;</span>keyCode<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">")"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> modifiers = e.<span style="color: #006600;">getModifiersEx</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">modString = <span style="color: #ff0000;">"modificadores = "</span> + modifiers;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tmpString = <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">getModifiersExText</span><span style="color: #66cc66;">&#40;</span>modifiers<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>tmpString.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>&amp;gt; <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">modString += <span style="color: #ff0000;">" ("</span> + tmpString + <span style="color: #ff0000;">")"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">modString += <span style="color: #ff0000;">" (sin modificadores)"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">actionString = <span style="color: #ff0000;">"¿Tecla de acción? "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>e.<span style="color: #006600;">isActionKey</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">actionString += <span style="color: #ff0000;">"SI"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">actionString += <span style="color: #ff0000;">"NO"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString = <span style="color: #ff0000;">"Ubicación tecla: "</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> location = e.<span style="color: #006600;">getKeyLocation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>location == <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">KEY_LOCATION_STANDARD</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString += <span style="color: #ff0000;">"standard"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>location == <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">KEY_LOCATION_LEFT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString += <span style="color: #ff0000;">"izquierda"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>location == <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">KEY_LOCATION_RIGHT</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString += <span style="color: #ff0000;">"derecha"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>location == <a href="http://www.google.com/search?q=allinurl%3AKeyEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">KeyEvent</span></a>.<span style="color: #006600;">KEY_LOCATION_NUMPAD</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString += <span style="color: #ff0000;">"numpad"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// (location == KeyEvent.KEY_LOCATION_UNKNOWN)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">locationString += <span style="color: #ff0000;">"desconocido"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayArea.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span>s + nuevaLinea</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">"    "</span> + keyString + nuevaLinea</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">"    "</span> + modString + nuevaLinea</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">"    "</span> + actionString + nuevaLinea</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+ <span style="color: #ff0000;">"    "</span> + locationString + nuevaLinea<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">displayArea.<span style="color: #006600;">setCaretPosition</span><span style="color: #66cc66;">&#40;</span>displayArea.<span style="color: #006600;">getDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getLength</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Se crea la GUI y se muestra.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> createAndShowGUI<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Se crea y setea la ventana.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJFrame+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JFrame</span></a> frame = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJFrame+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JFrame</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"KeyEventDemo"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">frame.<span style="color: #006600;">setDefaultCloseOperation</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AJFrame+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JFrame</span></a>.<span style="color: #006600;">EXIT_ON_CLOSE</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Se crea y setea el content pane.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJComponent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JComponent</span></a> newContentPane = <span style="color: #000000; font-weight: bold;">new</span> KeyEventDemo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">newContentPane.<span style="color: #006600;">setOpaque</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//content panes deben ser opacos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">frame.<span style="color: #006600;">setContentPane</span><span style="color: #66cc66;">&#40;</span>newContentPane<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Muestra la ventana</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">frame.<span style="color: #006600;">pack</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">frame.<span style="color: #006600;">setVisible</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Creando y mostrando la gui de esta aplicación.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javax.<span style="color: #006600;">swing</span>.<a href="http://www.google.com/search?q=allinurl%3ASwingUtilities+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">SwingUtilities</span></a>.<span style="color: #006600;">invokeLater</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Runnable</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> run<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">createAndShowGUI<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/02/keyevent-simple-en-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SDK v1.1 de Android ya está disponible</title>
		<link>http://www.creations.cl/2009/02/sdk-v11-de-android-ya-esta-disponible/</link>
		<comments>http://www.creations.cl/2009/02/sdk-v11-de-android-ya-esta-disponible/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 13:33:19 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[desarrollo]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=500</guid>
		<description><![CDATA[El software que nos permite desarrollar aplicaciones que corran en equipos con Android como Sistema Operativo, ha sido actualizado a la versión 1.1 release 1.
Según se informa en la página de los desarrolladores, los cambios incluidos en esta nueva versión no son muchos, pero recomiendan actualizarla con el objeto de aprovechar nuevas APIs y una [...]]]></description>
			<content:encoded><![CDATA[<p>El software que nos permite desarrollar aplicaciones que corran en equipos con Android como Sistema Operativo, ha sido actualizado a la versión 1.1 release 1.</p>
<p>Según se informa en la página de los desarrolladores, los cambios incluidos en esta nueva versión no son muchos, pero recomiendan actualizarla con el objeto de aprovechar nuevas APIs y una nueva imagen del emulador.</p>
<p style="text-align: center;">
<div id="attachment_501" class="wp-caption aligncenter" style="width: 476px">
<div class="MultiBoxHelp" id="MultiBoxHelp"><a href="http://www.rutschmann.biz" title="powered by Wordpress Multibox Plugin v1.3.5" target="_blank"><img src="http://www.creations.cl/wp-content/plugins/wordpress-multibox-plugin/images/help.png" alt="powered by Wordpress Multibox Plugin v1.3.5" title="powered by Wordpress Multibox Plugin v1.3.5"></a></div>
<p><a href="http://www.creations.cl/wp-content/uploads/2009/02/android.jpg"  class="wmp" id="wmp5"><img class="size-full wp-image-501" style="border: 1px solid black; padding: 2px; background-color: #F77;" title="android" src="http://www.creations.cl/wp-content/uploads/2009/02/android.jpg" alt="android sdk" width="466" height="170" /></a><p class="wp-caption-text">android sdk</p></div>
<p>El detalle de las modificaciones que incluye la actualización se pueden ver en <a href="http://developer.android.com/sdk/android-1.1.html" target="_blank">este link</a>. Para quienes deseen descargarla, lo pueden hacer desde <a href="http://developer.android.com/sdk/1.1_r1/index.html" target="_blank">este otro link</a>.
<div style="display: none;" class="wmpDesc wmp5">android sdk</div>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/02/sdk-v11-de-android-ya-esta-disponible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculadora simple con Java</title>
		<link>http://www.creations.cl/2009/01/calculadora-simple-con-java/</link>
		<comments>http://www.creations.cl/2009/01/calculadora-simple-con-java/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 12:51:36 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[j2ee]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=261</guid>
		<description><![CDATA[Para todos nuestros amigos programadores que se setán recién iniciando en el tema, les tengo un pequeño tip para realizar una calculadora bastante simple, no me maten pero está hecha en una sola clase, les dije, es sólo un ejemplo.
Espero les sirva para poder hacer pruebas y familiarizarse con el lenguaje.




Acá el código fuente de [...]]]></description>
			<content:encoded><![CDATA[<p>Para todos nuestros amigos programadores que se setán recién iniciando en el tema, les tengo un pequeño tip para realizar una calculadora bastante simple, no me maten pero está hecha en una sola clase, les dije, es sólo un ejemplo.</p>
<p>Espero les sirva para poder hacer pruebas y familiarizarse con el lenguaje.</p>
<p style="text-align: center;">
<div class="MultiBoxHelp" id="MultiBoxHelp"><a href="http://www.rutschmann.biz" title="powered by Wordpress Multibox Plugin v1.3.5" target="_blank"><img src="http://www.creations.cl/wp-content/plugins/wordpress-multibox-plugin/images/help.png" alt="powered by Wordpress Multibox Plugin v1.3.5" title="powered by Wordpress Multibox Plugin v1.3.5"></a></div>
<p><a href="http://www.creations.cl/wp-content/uploads/2009/01/calculadora.jpg"  class="wmp" id="wmp7"><img class="aligncenter size-full wp-image-262" title="calculadora" src="http://www.creations.cl/wp-content/uploads/2009/01/calculadora.jpg" alt="calculadora simple en java" width="200" height="200" /></a></p>
<p><span id="more-261"></span></p>
<p>Acá el código fuente de la calculadora.</p>
<div class="igBar"><span id="ljava-4"><a href="#" onclick="javascript:showPlainTxt('java-4'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-4">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package calculadora;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.swing.*;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.awt.*;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.awt.event.*;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calculadora <span style="color: #000000; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=allinurl%3AJFrame+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JFrame</span></a> <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?q=allinurl%3AActionListener+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">ActionListener</span></a>  <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">boolean</span> nuevo = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">float   resultado_total = <span style="color: #cc66cc;color:#800000;">0</span>.0f;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>  ultimo = <span style="color: #ff0000;">"="</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3ALabel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Label</span></a> pantalla = <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AButton+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Button</span></a> b;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AJPanel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JPanel</span></a> panel, panel2;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> Calculadora<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">setTitle<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Calculadora"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">setSize<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">200</span>, <span style="color: #cc66cc;color:#800000;">200</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Pantalla<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Teclado<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> Pantalla<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJPanel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JPanel</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color: #006600;">setLayout</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AGridLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">GridLayout</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3ALabel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Label</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"0"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setAlignment</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3ALabel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Label</span></a>.<span style="color: #006600;">RIGHT</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setForeground</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">black</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setBackground</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">white</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>pantalla<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"North"</span>, panel<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> Teclado <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel2 = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AJPanel+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">JPanel</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel2.<span style="color: #006600;">setLayout</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AGridLayout+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">GridLayout</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">4</span>, <span style="color: #cc66cc;color:#800000;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"7"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"8"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"9"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"C"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"4"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"5"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"6"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"*"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"√"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"1"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"2"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"3"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"-"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"AC"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"0"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"+/-"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"+"</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addBoton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"="</span>, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a>.<span style="color: #006600;">red</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Center"</span>, panel2<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> addBoton<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> n, <a href="http://www.google.com/search?q=allinurl%3AColor+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Color</span></a> color<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">b = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AButton+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Button</span></a><span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">b.<span style="color: #006600;">setForeground</span><span style="color: #66cc66;">&#40;</span>color<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel2.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">b.<span style="color: #006600;">addActionListener</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">this</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> actionPerformed<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AActionEvent+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">ActionEvent</span></a> event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> digit   = event.<span style="color: #006600;">getActionCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> s     = pantalla.<span style="color: #006600;">getText</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Logic based in a source of Santiago PavÃ³n</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">float  valor = <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">valor = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AFloat+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Float</span></a><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">floatValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!digit.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"C"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"0123456789"</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>digit<span style="color: #66cc66;">&#41;</span> != -<span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>nuevo<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span>digit<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span>s + digit<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>digit.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>nuevo<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"0."</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span>s + digit<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>digit.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sqrt"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">valor = <span style="color: #66cc66;">&#40;</span>float<span style="color: #66cc66;">&#41;</span><a href="http://www.google.com/search?q=allinurl%3AMath+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Math</span></a>.<span style="color: #006600;">sqrt</span><span style="color: #66cc66;">&#40;</span>valor<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>valor<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>digit.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"+/-"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">valor = -valor;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>valor<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>digit.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"C"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">resultado_total  = <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"0"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ultimo = <span style="color: #ff0000;">"="</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">char c = ultimo.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'='</span>: resultado_total  = valor; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'+'</span>: resultado_total += valor; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'-'</span>: resultado_total -= valor; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'*'</span>: resultado_total *= valor; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'/'</span>: resultado_total /= valor; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ultimo = digit;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">nuevo = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pantalla.<span style="color: #006600;">setText</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>resultado_total<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Calculadora cal = <span style="color: #000000; font-weight: bold;">new</span> Calculadora<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cal.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y para los más<span style="text-decoration: line-through;"> flojos</span> apurados les dejo el <a href="http://www.creations.cl/wp-content/uploads/2009/01/testeos.zip">workspace completo para eclipse.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/01/calculadora-simple-con-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>switch &#8211; case en java</title>
		<link>http://www.creations.cl/2009/01/switch-case-en-java/</link>
		<comments>http://www.creations.cl/2009/01/switch-case-en-java/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 14:41:42 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[j2ee]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=194</guid>
		<description><![CDATA[Una de las mayores dificultades que yo mismo tengo es de recordar aquel código que casi nunca usamos, en mi caso es el switch-case, debido a mi costumbre a usar bloques for y la poca necesidad de usar switch-case, como me he dado cuenta que a muchos les pasa me dispuse a escribir un ejemplo [...]]]></description>
			<content:encoded><![CDATA[<p>Una de las mayores dificultades que yo mismo tengo es de recordar aquel código que casi nunca usamos, en mi caso es el switch-case, debido a mi costumbre a usar bloques for y la poca necesidad de usar switch-case, como me he dado cuenta que a muchos les pasa me dispuse a escribir un ejemplo acá.</p>
<p>EN JAVA la sentencia es Switch con la siguiente estructura</p>
<div class="igBar"><span id="ljava-7"><a href="#" onclick="javascript:showPlainTxt('java-7'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-7">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>variable<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> valor_literal:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">codigo que ejecutamos;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> otro_valor_literal:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">codigo que ejecutamos;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">default:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">codigo que ejecutamos;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Si no les queda muy claro les pondré un ejemplo práctico <img src='http://www.creations.cl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="igBar"><span id="ljava-8"><a href="#" onclick="javascript:showPlainTxt('java-8'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-8">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> mes;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span>mes<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">1</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Enero"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">2</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Febrero"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">3</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Marzo"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">4</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Abril"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">5</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"May0"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">6</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Junio"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">7</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Julio"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">8</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Agosto"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">9</span>:&nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Septiembre"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">10</span>: <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Octubre"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">11</span>: <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Noviembre"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> <span style="color: #cc66cc;color:#800000;">12</span>: <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Diciembre"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como podemos ver, la variable mes toma siempre solo un valor, por ejemplo 2, por lo tanto cae en el switch-case y cuando llega al case 2 imprime febrero y sale del bloque, es una forma más elegante y óptima de escribir nuestro código, dado que esta misma función la podemos hacer con un gran bloque de if y else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/01/switch-case-en-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT : Google Web Toolkit</title>
		<link>http://www.creations.cl/2009/01/gwt-google-web-toolkit/</link>
		<comments>http://www.creations.cl/2009/01/gwt-google-web-toolkit/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 01:22:00 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[informática]]></category>
		<category><![CDATA[j2ee]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=161</guid>
		<description><![CDATA[Como muchos saben hace un par de meses que estoy trabajando con GWT, lo que significa Google Web Toolkit, así que me decidí a escribir un poco sobre este tema, si bien esste blog ha sido concebido como una ayuda para la porgramación, se ha ido llenando de humor y anécdotas, si bien también era [...]]]></description>
			<content:encoded><![CDATA[<p>Como muchos saben hace un par de meses que estoy trabajando con GWT, lo que significa Google Web Toolkit, así que me decidí a escribir un poco sobre este tema, si bien esste blog ha sido concebido como una ayuda para la porgramación, se ha ido llenando de humor y anécdotas, si bien también era uno de los objetivos de este proyecto, empezaremos a equilibrar un poco la balanza.</p>
<div class="MultiBoxHelp" id="MultiBoxHelp"><a href="http://www.rutschmann.biz" title="powered by Wordpress Multibox Plugin v1.3.5" target="_blank"><img src="http://www.creations.cl/wp-content/plugins/wordpress-multibox-plugin/images/help.png" alt="powered by Wordpress Multibox Plugin v1.3.5" title="powered by Wordpress Multibox Plugin v1.3.5"></a></div>
<p><a href="http://code.google.com/webtoolkit/"></a><a href="http://www.creations.cl/wp-content/uploads/2009/01/gwt.png"  class="wmp" id="wmp9"><img class="alignleft size-full wp-image-163" style="border: 1px solid black; padding: 2px; spaccing: 2px;" title="gwt" src="http://www.creations.cl/wp-content/uploads/2009/01/gwt.png" alt="gwt" width="97" height="51" /></a>Google Web Toolkit es una herramienta de desarrollo AJAX de Google destinada a desarrolladores Java. Las aplicaciones web (tanto GUI -Graphical User Interface- como RPC -Remote Procedure Call-) se escriben en Java usando el API GWT. Después los archivos Java se compilan en archivos JavaScript compactos, ofuscados y específicos del navegador. Un pequeño código de carga en JavaScript determina que archivos de script específico del navegador se deben utilizar dependiendo del navegador cliente. La librería API está licenciada bajo licencia Apache 2.0.</p>
<p><span id="more-161"></span></p>
<p>La principal fuente de documentación de GWT se encuentra en la <a href="http://code.google.com/webtoolkit/documentation/">página de documentación oficial</a> aunque también existen varios tutoriales en la web:</p>
<ul>
<li><a href="http://www-128.ibm.com/developerworks/library/j-ajax4/">Ajax for Java developers: Exploring the Google Web Toolkit</a></li>
<li><a href="http://today.java.net/lpt/a/301">Kickstarting Google Web Toolkit on the Client Side</a></li>
<li><a href="http://blogs.zdnet.com/Burnette/?p=122">Getting started with Google Web Toolkit (GWT)</a></li>
<li><a href="http://www.xml.com/pub/a/2006/07/12/google-web-toolkit-ajax-java-ant-xml.html">Google Web Toolkit</a></li>
<li><a href="http://www.onjava.com/pub/a/onjava/2006/05/31/working-with-google-web-toolkit.html">Working with the Google Web Toolkit</a></li>
<li><a href="http://google.wikia.com/wiki/Google_Web_Toolkit">Google Web Toolkit</a></li>
<li><a href="http://google.wikia.com/wiki/Jump_Start_Your_AJAX_Development_with_the_Google_Web_Toolkit">Jump Start Your AJAX Development with the Google Web Toolkit</a></li>
<li><a href="http://angel.hurtado.googlepages.com/tutorialgwt">Tutorial GWT</a></li>
</ul>
<p>Además, las novedades de la herramienta se van presentando en <a href="http://googlewebtoolkit.blogspot.com/">el blog oficial</a>.</p>
<p>Existe algún soporte en varios editores, aunque de momento bastante limitado.</p>
<p>Para el editor <a href="http://www.eclipse.org/">Eclipse</a>, existen varios plugins:</p>
<ul>
<li><a href="http://www.googlipse.com/">Googlipse</a>:  De momento bastante limitado</li>
<li><a href="http://code.google.com/p/gwt-tooling/">GWT Tooling</a>:  Basado en el anterior e incorpora alguna mejora</li>
<li><a href="http://www.wirelexsoft.com/VistaFei.html">VistaFei</a>: Aunque lo venden como un editor completo, se trata de un Eclipse con varios plug-ins desarrollados por ellos (no se pueden descargar independientemente, pero es posible aislarlos de una versión completa para incorporarlo posteriormente a una versión del eclipse ya instalada). Incorpora un editor visual. El problema actual de este editor es que cada vez que se regenera una pantalla desde el editor, se reemplaza completamente el código.</li>
<li><a href="http://www.instantiations.com/gwtdesigner/">GWT Designer</a></li>
</ul>
<p>Para el editor <a href="http://www.jetbrains.com/idea/">IntelliJ</a> tenemos:</p>
<ul>
<li><a href="http://www.jetbrains.net/confluence/display/IDEADEV/GWT+Studio+plugin">GWT Studio</a></li>
</ul>
<p>También hay disponibles varios componentes desarrollados por terceras partes para añadir a los que trae por defecto el framework. Algunos sitios que los recopilan son:</p>
<ul>
<li><a href="http://gwt.components.googlepages.com/">GWT Component Library</a></li>
<li><a href="http://gwt-widget.sourceforge.net/">GWT Widget Library</a></li>
<li><a href="http://jwc.sourceforge.net/cgi-bin/bin/view/Main/WebHome">JWC - Java Web Components</a></li>
</ul>
<p>Aunque la idea que propone la herramienta parece bastante interesante, a la hora de crear una aplicación nos podemos encontrar con algunos problemas:</p>
<ul>
<li>La documentación está muy restringida a sencillos ejemplos pero sin dar mucha información para realizar aplicaciones completas (incluso se comenta que en Google liberaron una parte muy pequeña de los componente que realmente utilizan para sus aplicaciones).</li>
<li><del datetime="2007-01-10T17:06:38+00:00"></del>Desde el 12 de Diciembre del 2006 el compilador de <a href="http://googlewebtoolkit.blogspot.com/2006/12/gwt-13-release-candidate-is-100-open_12.html">GWT es Open Source</a></li>
<li>Es difcil encontrar errores cuando la aplicación simplemente no arranca ya que la ejecución de la misma, en desarrollo, está “oculta” en unas clases lanzadoras de Google.</li>
<li>Todos los archivos deben estar codificados en UTF-8 para que salgan los mensajes correctamente.</li>
<li>La conversión de código Java a JavaScript hace que la carga de la página pueda ser algo mas lenta aunque la ejecución, una vez cargada, será más rápida (siempre dependiendo de la potencia de la máquina del cliente).</li>
</ul>
<p><strong>Algunas aplicaciones de ejemplo</strong></p>
<ul>
<li><a href="http://code.google.com/webtoolkit/documentation/examples/">Google Web Toolkit Example Applications</a>: Sencillas aplicaciones de ejemplo oficiales.</li>
<li><a href="http://octagonsoftware.com/home/mark/gwthangman/">GWT Hangman</a>: Juego del ahorcado realizado por Mark Roth</li>
<li><a href="http://www.gpokr.com/">Gpokr</a>: Juego de poker animado</li>
<li><a href="http://www.mynetimages.com/">myNetImages</a>: Sitio de compartición de fotografías desarrollado usando Google Web toolkit.</li>
<li><a href="http://s2.lodgon.com/ajax/LodgonDemo.html">RSS Reader</a>: Aplicación básica de lectura de RSS.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/01/gwt-google-web-toolkit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generador de Rut y Validador</title>
		<link>http://www.creations.cl/2009/01/generador-de-rut-y-validador/</link>
		<comments>http://www.creations.cl/2009/01/generador-de-rut-y-validador/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 18:34:46 +0000</pubDate>
		<dc:creator>Ancelot</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[generador de rut]]></category>
		<category><![CDATA[informática]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[rut]]></category>
		<category><![CDATA[verificador de rut]]></category>

		<guid isPermaLink="false">http://www.creations.cl/?p=63</guid>
		<description><![CDATA[Muchos han esatdo buscando  una forma de validar si un RUT es válido o no, pero también hay muchos que necesitan probar sus aplicaciones y están usando sus propios RUTs, pero ¿qué pasa cuando necesitas hacer una prueba masivamente?, acá te traigo la solución...
El primer método te devolverá un char con el texto del dígito [...]]]></description>
			<content:encoded><![CDATA[<p>Muchos han esatdo buscando  una forma de validar si un RUT es válido o no, pero también hay muchos que necesitan probar sus aplicaciones y están usando sus propios RUTs, pero ¿qué pasa cuando necesitas hacer una prueba masivamente?, acá te traigo la solución...</p>
<p><span id="more-63"></span>El primer método te devolverá un char con el texto del dígito verificador al RUT que se recibe por parámetro, pero, ¿por qué devuelve char?, fácil, el dígito verificador puede ser una "K", por lo que se devuelve como código ASCII del carácter correspondiente.</p>
<p>Por ejemplo</p>
<div class="igBar"><span id="ljava-13"><a href="#" onclick="javascript:showPlainTxt('java-13'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-13">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#40;</span>char<span style="color: #66cc66;">&#41;</span><span style="color: #cc66cc;color:#800000;">45</span> <span style="color: #808080; font-style: italic;">//- eso corresponde a cero 0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#40;</span>char<span style="color: #66cc66;">&#41;</span><span style="color: #cc66cc;color:#800000;">75</span> <span style="color: #808080; font-style: italic;">//- eso corresponde a K </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Acá el método que me devuelve el Dígito Verificador.</p>
<div class="igBar"><span id="ljava-14"><a href="#" onclick="javascript:showPlainTxt('java-14'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-14">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> char obtieneDV<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> rut<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> m = <span style="color: #cc66cc;color:#800000;">0</span>, s = <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>; rut != <span style="color: #cc66cc;color:#800000;">0</span>; rut /= <span style="color: #cc66cc;color:#800000;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s = <span style="color: #66cc66;">&#40;</span>s + rut % <span style="color: #cc66cc;color:#800000;">10</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">9</span> - m++ % <span style="color: #cc66cc;color:#800000;">6</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> % <span style="color: #cc66cc;color:#800000;">11</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>char<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>s != <span style="color: #cc66cc;color:#800000;">0</span> ? s + <span style="color: #cc66cc;color:#800000;">47</span> : <span style="color: #cc66cc;color:#800000;">75</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El método es super sencillo, pero necesitamos probarlo. Para esto vamos a hacer un for que me genere números al azar que haremos pasar por RUTs y obtendremos el dígito verificador que corresponda, si bien, muchos de estos RUTs no serán reales, sí serán validos y nos servirtán para testear nuestra aplicación.</p>
<div class="igBar"><span id="ljava-15"><a href="#" onclick="javascript:showPlainTxt('java-15'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-15">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> metodoCualquiera<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i=<span style="color: #cc66cc;color:#800000;">0</span>; i&amp;lt;<span style="color: #cc66cc;color:#800000;">100</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> rut = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AMath+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Math</span></a>.<span style="color: #006600;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;color:#800000;">30000000</span>+<span style="color: #cc66cc;color:#800000;">10000000</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">GWT.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"RUT :"</span>+<a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>rut<span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">"-"</span>+obtieneDV<span style="color: #66cc66;">&#40;</span>rut<span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>rut<span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">"-"</span>+obtieneDV<span style="color: #66cc66;">&#40;</span>rut<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> char obtieneDV<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> rut<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> m = <span style="color: #cc66cc;color:#800000;">0</span>, s = <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>; rut != <span style="color: #cc66cc;color:#800000;">0</span>; rut /= <span style="color: #cc66cc;color:#800000;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s = <span style="color: #66cc66;">&#40;</span>s + rut % <span style="color: #cc66cc;color:#800000;">10</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">9</span> - m++ % <span style="color: #cc66cc;color:#800000;">6</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> % <span style="color: #cc66cc;color:#800000;">11</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>char<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>s != <span style="color: #cc66cc;color:#800000;">0</span> ? s + <span style="color: #cc66cc;color:#800000;">47</span> : <span style="color: #cc66cc;color:#800000;">75</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Así tendremos una consola con 100 RUTs totalmente válidos y útiles al momento de hacer testing.</p>
<p>Para los que también necesiten un validador de RUT.</p>
<p>Este método es parecido al anterior, sólo que recibe un parámetro má, el DV, así calcula el DV que corresponde al RUT introducido y lo compara con el DV que nosotros le proporcionamos, nos devolverá un "true" en caso de ser iguales y un "false" en caso de no corresponder.</p>
<div class="igBar"><span id="ljava-16"><a href="#" onclick="javascript:showPlainTxt('java-16'); return false;">TEXTO PLANO</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-16">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> verificarRut<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> rut, char dv<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span> m = <span style="color: #cc66cc;color:#800000;">0</span>, s = <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>; rut != <span style="color: #cc66cc;color:#800000;">0</span>; rut /= <span style="color: #cc66cc;color:#800000;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">s = <span style="color: #66cc66;">&#40;</span>s + rut % <span style="color: #cc66cc;color:#800000;">10</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">9</span> - m++ % <span style="color: #cc66cc;color:#800000;">6</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> % <span style="color: #cc66cc;color:#800000;">11</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">return</span> dv == <span style="color: #66cc66;">&#40;</span>char<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>s != <span style="color: #cc66cc;color:#800000;">0</span> ? s + <span style="color: #cc66cc;color:#800000;">47</span> : <span style="color: #cc66cc;color:#800000;">75</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.creations.cl/2009/01/generador-de-rut-y-validador/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

