0 Replies Latest reply: Feb 10, 2010 5:24 AM by 843851 RSS

    HGraphicButton

    843851
      Hi! I am trying to do a HGraphicButton, that changes his image when it focused or actioned. I mean, I use this constructor : butt3 = new HGraphicButton(imagen, imagenSelec, imagenActiv, 30, 100, 153, 52);

      The focus works well, but when I action the button, the image doesn't change.

      I am using the xletview emulator

      I copy the code to understand better...

      ....

      public void startXlet() throws XletStateChangeException {
      //scene = HSceneFactory.getInstance().getDefaultHScene();
      //Rectangle rect = scene.getBounds();
      //setBounds(rect);
      System.out.println("Estoy en start");
      butt1 = new HTextButton("Button 1");
      try {
      Image imagen = Toolkit.getDefaultToolkit().getImage("img/BVideos.jpg");
      Image imagenSelec = Toolkit.getDefaultToolkit().getImage("img/BVideosSelec.jpg");
      Image imagenActiv = Toolkit.getDefaultToolkit().getImage("img/BVideosActivado.jpg");
      butt3 = new HGraphicButton(imagen, imagenSelec, imagenActiv, 30, 100, 153, 52);
      imagen = Toolkit.getDefaultToolkit().getImage("img/BNoticias.jpg");
      imagenSelec = Toolkit.getDefaultToolkit().getImage("img/BNoticiasSelec.jpg");
      butt4 = new HGraphicButton(imagen, imagenSelec, null, 30, 200, 153, 52);

      } catch (Exception e) {
      System.out.println("Error al cargar imagen...");
      }

      butt1.setBounds(30, 30, 120, 40);
      cont1 = new HContainer(0, 0, 550, 550);
      cont1.setBackground(Color.blue);
      cont1.setForeground(new DVBColor(122, 14, 125, 255));
      butt3.setFocusTraversal(butt4, butt4, butt4, butt4);
      butt4.setFocusTraversal(butt3, butt3, butt3, butt3);
      *butt3.addHActionListener(new HActionListener() {*

      *public void actionPerformed(ActionEvent e) {*
      System.out.println(" I am here");
      *}*
      *});*
      //just some alignment
      butt3.setVerticalAlignment(HVisible.VALIGN_TOP);
      butt3.setHorizontalAlignment(HVisible.HALIGN_LEFT);
      butt4.setVerticalAlignment(HVisible.VALIGN_TOP);
      butt4.setHorizontalAlignment(HVisible.HALIGN_LEFT);

      cont1.add(butt3);
      cont1.add(butt4);
      this.add(cont1);

      this.setVisible(true);
      scene.add(this);
      scene.setVisible(true);
      butt3.requestFocus();