J'ai écrit un champ d'édition personnalisé avec bordure à l'aide JDE4.2.1 Ce champ est ensuite ajouté à un VerticalLayoutManager et instancié en tant que tel:problème alignement champ d'édition personnalisé pour BlackBerry
BorderEditField bef = new BorderEditField("Enter a value: ", null, 6,
BorderEditField.FIELD_RIGHT | BorderEditField.FILTER_NUMERIC);
Cependant, quel que soit le style que je spécifie (FIELD_HCENTER), le champ est toujours aligné à gauche. Y at-il quelque chose d'évident que je pourrais manquer ici? Essayé sur les différentes versions de JDE avec le même résultat ...
public class BorderEditField extends BasicEditField {
public BorderEditField(String label, String initialValue, int maxNumChars, long style)
{
super(label, initialValue, maxNumChars, style);
}
private int iRectX = getFont().getAdvance(getLabel());
private int iRectWidth = (getMaxSize() * getFont().getAdvance("X")) + 16;
public int getPreferredWidth() {
return Display.getWidth();
}
public void layout(int width, int height) {
super.layout(width, getPreferredHeight());
setExtent(width, getPreferredHeight());
}
public void paint(Graphics g) {
super.paint(g);
if (isFocus()) {
g.setColor(Color.RED);
g.setGlobalAlpha(220);
g.drawRect(iRectX, 0, iRectWidth, getPreferredHeight());
} else {
g.setColor(Color.BLACK);
g.setBackgroundColor(Color.DARKBLUE);
g.setGlobalAlpha(150);
g.drawRect(iRectX, 0, iRectWidth, getPreferredHeight());
}
}
}
Merci.
essayées avec USE_ALL_WIDTH sans succès. Les champs personnalisés sont contenus dans un VerticalLayoutManager et d'autres champs d'édition semblent être correctement alignés. Cela me donne l'impression qu'il me manque quelque chose dans le domaine personnalisé lui-même. – emt14