How make the HContainer navigable?

Hello, I am trying to make my own 揅omponent? I want put some buttons pictures (HStaticIcon) to HContainer. I wont add first HStaticIcon using HContainer.add(HComponent) and next by using HContainer.addAfter(HComponent). And now there is my problem I don抰 know what interface I have to implements to my HContainer to make him focusable and navigable. I think I have to implements 揌State,HNavigable,HFocusListener,HNavigationInputPreferred?but I don抰 know how. I don抰 know what I have to do in inherited methods like:

public void setMove(int keyCode, HNavigable target) {

}

public HNavigable getMove(int keyCode) {

return null;

}

public void setFocusTraversal(HNavigable up, HNavigable down, HNavigable left, HNavigable right) {

addHFocusListener(this);

this.up = up;

this.down = down;

this.left = left;

this.right = right;

}

Is here anybody who can help me? Thanks you very much for your help. My functionless code is here:

public class PersonAgeMenu extends HContainer implements HState,HNavigable,HFocusListener,HNavigationInputPreferred{

private HStaticIcon v6_12;

private HStaticIcon v12_18;

boolean isSelected = false;

private String selectedItem = new String();

private HNavigable up;

private HNavigable down;

private HNavigable left;

private HNavigable right;

private int i[]=new int[4];

/** Creates a new instance of personSexMenu */

public PersonAgeMenu(int x,int y) {

this.setBounds(x,y,125,25);

this.setLayout(new BorderLayout());

init();

}

public void init(){

v6_12 = new HStaticIcon(Toolkit.getDefaultToolkit().getImage("Button1.jpg"),0,0,125,25);

v6_12.setDefaultSize(new Dimension(125,25));

v6_12.setResizeMode(HStaticIcon.RESIZE_NONE);

v6_12.setName("v6_12");

v6_12.setVisible(true);

v12_18 = new HStaticIcon(Toolkit.getDefaultToolkit().getImage("Button2.jpg"),0,0,125,25);

v12_18.setDefaultSize(new Dimension(125,25));

v12_18.setResizeMode(HStaticIcon.RESIZE_NONE);

v12_18.setName("v12_18");

v12_18.setVisible(true);

this.add(v6_12);

this.addAfter(v12_18,v6_12);

this.setVisible(true);

this.addHFocusListener(this);

System.out.println("gggggggggggggggg");

}

public void switchMenu(){

if (this.getComponent(0)==v6_12){

this.popToFront(v12_18);

this.repaint();

}

else{

this.popToFront(v6_12);

this.repaint();

}

}

public String getSelectedItem(){

return this.getComponent(0).getName();

}

public PersonAgeMenu getMenuAge(){

return this;

}

public HStaticIcon getMenHStaticIcon(){

return v6_12;

}

public HStaticIcon getWomenHStaticIcon(){

return v12_18;

}

public HStaticIcon getSelectedIcon(){

return (HStaticIcon) this.getComponent(0);

}

public void repaint(){

super.repaint();

}

public void setMove(int keyCode, HNavigable target) {

}

public HNavigable getMove(int keyCode) {

return null;

}

public void setFocusTraversal(HNavigable up, HNavigable down, HNavigable left, HNavigable right) {

addHFocusListener(this);

this.up = up;

this.down = down;

this.left = left;

this.right = right;

}

public boolean isSelected() {

return isSelected;

}

public void setGainFocusSound(HSound sound) {

}

public void setLoseFocusSound(HSound sound) {

}

public HSound getGainFocusSound() {

return null;

}

public HSound getLoseFocusSound() {

return null;

}

public void addHFocusListener(HFocusListener l) {

super.addFocusListener(l);

}

public void removeHFocusListener(HFocusListener l) {

}

public int[] getNavigationKeys() {

int i[]=new int[4];

i[0] = org.havi.ui.event.HRcEvent.VK_UP;

i[1] = org.havi.ui.event.HRcEvent.VK_DOWN;

i[2] = org.havi.ui.event.HRcEvent.VK_LEFT;

i[3] = org.havi.ui.event.HRcEvent.VK_RIGHT;

return i;

}

public void processHFocusEvent(HFocusEvent evt) {

System.out.println("OUHHHHHHHHHHHHHHHHHHHHHHHA");

int j[] = getNavigationKeys();

if (evt.getTransferId()==j[0]) this.setMove(evt.getTransferId(),up);

if (evt.getTransferId()==j[1]) this.setMove(evt.getTransferId(),down);

if (evt.getTransferId()==i[2]) this.setMove(evt.getTransferId(),left);

if (evt.getTransferId()==i[3]) this.setMove(evt.getTransferId(),right);

}

public void focusGained(FocusEvent e) {

if (e.getComponent()==this){

isSelected = true;

System.out.println("Tak瀍 sem zde ano či ne");

}

}

public void focusLost(FocusEvent e) {

}

}

[4902 byte] By [Miki_Koha] at [2007-11-27 6:08:08]
# 1
There are some examples about navigation on the MHP Knowledge Base atwww.mhp-knowledgebase.org/ , section Issue and solution database (registration is free).Greetings,Eva.
EVLa at 2007-7-12 17:10:07 > top of Java-index,Java Mobility Forums,Consumer and Commerce...