9 Replies Latest reply: May 13, 2009 1:24 AM by 843851 RSS

    problem with setVisible();

    843851
      Hy,

      as a beginning MHP programmer (and beginning programmer :) ), I am experiencing some problems with my code. More in particular I have a question about the setVisible() method.

      Here is some sample code to illustrate my problem. I have tried to get it as basic possible. The program starts with a green rectangle on screen. When the green button is pressed, it disapears. When the red button is pressed, it reappears.
      The problem is that it works with xletview and not on my adb developpers box. The green rectangle just stays there.

      I notice that when I look at the debug output of my box that the action of repainting is done when pushing the red button. But the action of clearing the screen isn't done when pushing the green button.

      I think that it could be some basic problem... Can someone help me out with this?


      Thanks

      Tom
      import java.awt.*;
      import java.awt.event.KeyEvent;
      import java.awt.event.KeyListener;
      import javax.tv.xlet.*;
      import org.havi.ui.*;
      import org.havi.ui.event.HRcEvent;
      
      public class SetVisibleTest extends Container implements Xlet, KeyListener {
      
           HScene scene;
      // this container displays a green rectangle on screen
           container1 container1 = new container1();
           
           
           public void initXlet(XletContext ctx) throws XletStateChangeException {
                
                setBounds(0,0,720,576);
                HSceneFactory factory = HSceneFactory.getInstance();
                HSceneTemplate hst = new HSceneTemplate();
                hst.setPreference(HSceneTemplate.SCENE_SCREEN_DIMENSION, new 
      org.havi.ui.HScreenDimension(1, 1), HSceneTemplate.REQUIRED);
                hst.setPreference(HSceneTemplate.SCENE_SCREEN_LOCATION, new 
      org.havi.ui.HScreenPoint(0, 0), HSceneTemplate.REQUIRED);
                scene = factory.getBestScene(hst);
                
      
                this.add(container1);
                container1.setBounds(0,0,720,576);
      
                scene.add(this);
                scene.setVisible(false);
                scene.addKeyListener((KeyListener)this);
           }
      
      
           public void startXlet() throws XletStateChangeException {
                
                System.out.println("startxlet");
                
                scene.setVisible(true);
                scene.requestFocus();
           }
      
      
           public void pauseXlet() {
                
           }
      
      
           public void destroyXlet(boolean unconditional) throws XletStateChangeException {
                
           }
      
           
      
           public void keyTyped(KeyEvent e) {
                
           }
      
           public void keyPressed(KeyEvent e) {
                System.out.println("a key is pressed");
                switch(e.getKeyCode()){
                case HRcEvent.VK_COLORED_KEY_0:
                System.out.println("0");
                container1.setVisible(true);
                System.out.println("container1.setVisible(true)");
                break;
                case HRcEvent.VK_COLORED_KEY_1:
                System.out.println("1");
                container1.setVisible(false);
                System.out.println("container1.setVisible(false)");
                break;
                }
           }
      
           public void keyReleased(KeyEvent e) {
      
                
           }
      
      
      
      }
      The code for the container class is
      public class container1 extends Container {
      
           container1() {
                
           }
           
            public void paint (Graphics g){
                 super.paint(g);
                g.setColor(Color.green);
                g.fillRect(100,100,300,300);
                System.out.println("paint container1");
           }
           
      }
        • 1. Re: problem with setVisible();
          843851
          Try calling container1.repaint() after you have changed it's visible property...
          • 2. Re: problem with setVisible();
            843851
            Which firmware version are you using?
            • 3. Re: problem with setVisible();
              843851
              Hy,

              thanks for the answer.

              So I changed the code (in bold what I changed). But this doesn't solve the problem. :(

              But without the repaint() function, the paint() function of container1 is called when the setVisible(true) is invoked (I can tell this, because I have inserted
              System.out.println("paint container1")
              in the paint() method. ). When setVisible(false) is called, some other action than paint() has to be done?

              Does my code works on your settop boxes?
                   public void keyPressed(KeyEvent e) {
                        System.out.println("a key is pressed");
                        switch(e.getKeyCode()){
                        case HRcEvent.VK_COLORED_KEY_0:
                        System.out.println("0");
                        container1.setVisible(true);
                        container1.repaint();
                        System.out.println("container1.setVisible(true)");
                        break;
                        case HRcEvent.VK_COLORED_KEY_1:
                        System.out.println("1");
                        container1.setVisible(false);
                        container1.repaint();
                        System.out.println("container1.setVisible(false)");
                        break;
                        }
                   }
              • 4. Re: problem with setVisible();
                843851
                Hy,

                I'll give you the full information about the box. It's already an old one ...
                If you speak of firmware, which of the following properties corresponds to that?

                System Information:

                MHP Version: 1.0.2
                MHP Profile: Interactive Broadcasting
                Manufacturer: ADB
                H/W Version: Q53Z
                S/W Version: Build 'v421'
                App. Version: 1.4.3


                Loader Info:

                H/W Info: ADB 5.2:254
                S/W Info: 3.070 32767

                Tom
                • 5. Re: problem with setVisible();
                  843851
                  Worked fine on my box!
                  I'm using an ADB Worldsat, H/W: T72X, S/W: Build 'v971_6'
                  • 6. Re: problem with setVisible();
                    843851
                    thanks!

                    Hmm... So the problem can be my settop box :) Someone else who can confirm? Is there a way to upgrade this box?


                    Tom
                    • 7. Re: problem with setVisible();
                      843851
                      Hi TDR,
                      I have tried your code on my ADB developer STB and it works well.
                      It is a firmware problem. My SW version is the latest. You can find it in the ADB support page.
                      After downloading you have to update your firmware wersion using the FastTerm loader (it is downloadable in the support area too).

                      I hope I help you.

                      By
                      • 8. Re: problem with setVisible();
                        843851
                        You are using version v421. This version is rather old and has several errors. Try to upgrade to a version v9xx.
                        • 9. Re: problem with setVisible();
                          843851
                          Hello earler i had put a question about ADB Developer STB since all of you have hands on experience with it. I am amazed to see my question disappear - may be that had something to do with me anyway I wanted to know if we would require any additional s/w or h/w tools that do not come as a package with ADB Developer STB to develop a full scale OCAP application.

                          In short do we require anything besides the ADB Developer STB for example object Carousals, transport streams, Multiplexers, Demodulators, HeadEnds and so on or having a developer STB is enough if i made myself clear.

                          Thanks and Regards
                          S@n9