Saturday, January 21, 2006

Apple el renacido competidor de Micro$oft



Todos saben la noticia de que apple vale > Dell, dicho por el propio Steve Jobs, bueno el problema es que Apple tambien se mudo a procesadores intel los cual quiere decir que COMPETIRA más directamente en el mercado contra M$ y no solo eso el valor de las acciones de Apple son ya > que las de M$.

Sun no se atras y Google ni se diga ;-).

Ha de esperarse muchas cosa de esta compañia este año. Y de las otras tambien ;-)

AAPL $ 79.035 3.4551 4.19% 60,585,718 NASDAQ-NM
MSFT $ 27.02 0.19 0.71% 60,382,450 NASDAQ-NM

JXTA P2P en Java

Teórico y lo más importante práctico tambien ;-) muestra como hacer un Hello JXTA!
http://www.onjava.com/pub/a/onjava/2001/04/25/jxta.html?page=1

Muy teórico pero importante sobre la arquitectura
http://www.javaworld.com/javaworld/jw-10-2001/jw-1019-jxta.html

Una pagina a tener en cuenta: http://www.jxta.org/

JXTA es un protocolo de P2P desarrollado por Sun y luego liberado como open source que se a convertido en estandar para la industria.

Friday, January 20, 2006

how to attach a MaskFormatter to a JFormattedTextField in the IDE's form editor?

Un pequeño tutorial de como manejar validaciones con java Studio Entreprise, puesto que me fue un poco trabajoso tuve que preguntarle al soporte como se hacia, y realmente es sencillo pero muy elaborado. Esta en ingles espero que se entienda ;-)

how to attach a MaskFormatter to a JFormattedTextField in the IDE's form editor?

1. Add JFormattedTextField to the form.

2. In Properties window, click ... button for formatterFactory property.

3. Select User Code radio button.

4. Enter the following example text into the text area:



new javax.swing.JFormattedTextField.AbstractFormatterFactory() {

public javax.swing.JFormattedTextField.AbstractFormatter

getFormatter(javax.swing.JFormattedTextField tf) {

try {

return new javax.swing.text.MaskFormatter("##-###");

} catch (java.text.ParseException pe) {

pe.printStackTrace();

}

return null;

}

}



5. Build and run the project and you've got a formatted text field that only accepts two digits, a hyphen, and three more digits (the hyphen is automatically inserted by the formatter).



--> On the other hand, are you asking how to validate the input when the form in which the formatted text field is contained is somehow dismissed (e.g. if the field were in a dialog In that case, the code which built and displayed the dialog will need an action listener on the button which accepts the user input, and this listener will retrieve the text from the field, validate it, and if it is incorrect, either display a message in a new dialog, or show an error message in a JLabel near the bottom or top of the dialog (commonly seen in Studio itself). If the input is valid, then dispose of (i.e. close) the original dialog and proceed as normal with the given user input.


--> Or, do you want to verify the input before the field loses focus? In that case, click the ... button next to the inputVerified property for the text field and add something like the following for the User Code:


new javax.swing.InputVerifier() {

public boolean verify(javax.swing.JComponent input) {

// validate user input

return true;

}

}

The code displaying the input dialog would need a counter, incremented each time the input was invalid, and show the error dialog only on the third attempt.


En forma de Bean

import java.awt.event.FocusListener;

import javax.swing.JFormattedTextField;
import javax.swing.text.MaskFormatter;

public class MaskFormattedTextField extends JFormattedTextField
implements java.io.Serializable {
private String mask = "";

public MaskFormattedTextField() {
addFocusListener(new FocusListener() {
public void focusGained(java.awt.event.FocusEvent e) {
selectAll();
}
public void focusLost(java.awt.event.FocusEvent e) {}
});
}

public final String getMask() {
return mask;
}

public final void setMask(final String m) {
mask = m;

try {
new MaskFormatter(mask).install(this);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
}
}

Wednesday, January 11, 2006

Asp.NET vs JSF

Una interesante comparativa de las dos tecnologias:

http://www.developer.com/net/asp/article.php/10917_3572721_1

Esto es para los amigos mios, para que esten claros en las diferencias que hay entre programar con asp.NET y JSF ( .NET Y JAVA como ustedes le llaman :-)

Es un buen analisis y toca todos los puntos en el desarrollo de un programa con las dos tecnologias.