Problema com Java tv - Xlets - XletView - Java TV API

0 respostas
JotaJota

Caros Amigos, Tudo bem?

Atualmente me interessei por Java TV API, Comecei varios projetos porem nenhum deles rodam quando eu tento rodar pelo XletView

Configuro o Manager Application fazendo referencia a uma classe que implementa a clase Xlet e os metodos basicos
porem na hora de rodar quando seleciono o ponteiro da aplicação: dá erro!
isso acotnece para todas as classes que eu tentei implementar!
Vou escrever aqui algumas das classes que implementei
seguido do erro que ambas produz.

Listagem 1
import xjavax.tv.xlet.Xlet;
import xjavax.tv.xlet.XletContext;
import xjavax.tv.xlet.XletStateChangeException;


public class FirstXletExample implements Xlet
{

	private XletContext context;

	private boolean hasBeenStarted;


	public FirstXletExample()
	{

	}


	public void initXlet(XletContext context) throws XletStateChangeException
	{
		// store a reference to the Xlet context that the Xlet is executing in
		this.context = context;

		// The Xlet has not yet been started for the first time, so set
		// this variable to false.
		hasBeenStarted = false;

		// Since this is a simple Xlet, we'll just print a message to the debug output
		System.out.println("The initXlet() method has been called.  Our Xlet context is " + context);

	}

 
	public void startXlet() throws XletStateChangeException
	{

		if (hasBeenStarted) {
			System.out.println("The startXlet() method has been called to resume the Xlet after it's been paused.  Hello again, world!");
		}
		else {
			System.out.println("The startXlet() method has been called to start the Xlet for the first time.  Hello, world!");

			// set the variable that tells us we have actually been started
			hasBeenStarted = true;
		}
	}


	public void pauseXlet()
	{
		// Since we have nothing to pause, we will tell the user that we are
		// pausing by printing a message on the debug output.
		System.out.println("The pauseXlet() method has been called.  Bedtime...");
	}


	public void destroyXlet(boolean unconditional) throws XletStateChangeException
	{

		if (unconditional) {
			// We have been ordered to terminate, so we obey the order politely and release any
			//scarce resources that we are holding.
			System.out.println("The destroyXlet() method has been called telling the Xlet to stop unconditionally.  Goodbye, cruel world!");
		}
		else {
			// We have had a polite request to die, so we can refuse this request if we want.
			System.out.println("The destroyXlet() method has been called requesting that the application stops, but giving it the choice.  So, I'll decide not to stop.");

			throw new XletStateChangeException("Please don't kill me!");
		}
	}
}
Listagem 2
import xjavax.tv.xlet.Xlet;
import xjavax.tv.xlet.XletContext;
import xjavax.tv.xlet.XletStateChangeException;


public class MySecondXlet implements Xlet
{

  private XletContext context;



  private boolean hasBeenStarted;



  public MySecondXlet()
  {

  }



  public void initXlet(XletContext context)
    throws XletStateChangeException
  {
    // store a reference to the Xlet context that the Xlet
    // is executing in
    this.context = context;

    // The Xlet has not yet been started for the first
    // time, so set this variable to false.
    hasBeenStarted = false;

    // Since this is a simple Xlet, we'll just print a
    // message to the debug output
    System.out.println("The initXlet() method has been" +
      " called.  Our Xlet context is " + context);
  }


  public void startXlet()
    throws XletStateChangeException
  {
    // Again, we print a message on the debug output to
    // tell the user that something is happening.  In
    // this case, what we print depends on whether the
    // Xlet is starting for the first time, or whether
    // it's been paused and is resuming

    // have we been started?
    if (hasBeenStarted) {
      System.out.println("The startXlet() method has" +
        " been called to resume the Xlet after it's" +
        " been paused.  Hello again, world!");
    }
    else {
      System.out.println("The startXlet() method has" +
        " been called to start the Xlet for the" +
        " first time.  Hello, world!");

      hasBeenStarted = true;
    }
  }



  public void pauseXlet()
  {
    // Since we have nothing to pause, we will tell the
    // user that we are pausing by printing a message on
    // the debug output.
    System.out.println("The pauseXlet() method has " +
      "been called. Bedtime...");
  }



  public void destroyXlet(boolean unconditional)
    throws XletStateChangeException
  {
    if (unconditional) {
      // We have been ordered to terminate, so we obey
      // the order politely and release any scarce
      // resources that we are holding.
      System.out.println("The destroyXlet() method has" +
        " been called telling the  Xlet to stop" +
        " unconditionally.  Goodbye, cruel world!");
    }
    else {
      // We have had a polite request to die, so we can
      // refuse this request if we want.
      System.out.println("The destroyXlet() method has" +
        " been called requesting that the application" +
        " stops, but giving it the choice.  So, I'll" +
        " decide not to  stop.");

      // Throwing an XletStateChangeException tells the
      // middleware that the application would like to
      // keep running  if it's allowed to.
      throw new XletStateChangeException(
        "Please don't kill me!");
    }
  }
}
Listagem 3
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import org.havi.ui.*;

import xjavax.tv.service.SIManager;
import xjavax.tv.service.Service;
import xjavax.tv.service.navigation.ServiceIterator;
import xjavax.tv.service.navigation.ServiceList;
import xjavax.tv.xlet.Xlet;
import xjavax.tv.xlet.XletContext;
import xjavax.tv.xlet.XletStateChangeException;

public class SimpleEPG implements Xlet, ActionListener, KeyListener {

    private XletContext context;
    private HScene scene;   
    private Panel panel = null;   
    private List slist = null;
    private List plist = null;
    private Button button = null;
    private SIManager si_manager = null;
    private Retriever retriever = null;
    
    public SimpleEPG() {
    }

    public void initXlet(XletContext xletContext) throws XletStateChangeException {
        context = xletContext;
        
        HSceneFactory hsceneFactory = HSceneFactory.getInstance();
        scene = hsceneFactory.getFullScreenScene(
                     HScreen.getDefaultHScreen().getDefaultHGraphicsDevice());
        scene.setSize(500, 400);
        scene.setLayout(null);
        scene.addKeyListener(this);
        
        panel = new Panel();
        panel.setBackground(Color.black); 
        scene.add(panel);
        panel.setBounds(0, 0, scene.getSize().height,scene.getSize().width - 50); 
        panel.setLayout(new GridLayout(2,1)); 
        slist = new List();
        slist.setBackground(Color.lightGray); 
        slist.addActionListener(this);
        slist.addKeyListener(this);
        panel.add(slist); 
        plist = new List();
        plist.setBackground(Color.lightGray); 
        panel.add(plist); 
        button = new Button("Refresh"); 
        button.setBackground(Color.darkGray);
        button.setForeground(Color.white); 
        button.addActionListener(this);
        scene.add(button); 
        button.setBounds(0,scene.getSize().width-50, 
        		scene.getSize().height, 50);

        scene.validate();
        scene.setVisible(true);
        scene.requestFocus();
        
        retriever = new Retriever();
        si_manager = SIManager.createInstance();        
    }

    public void startXlet() throws XletStateChangeException {
        panel.validate();    
        updateList(slist);  
    }

    public void pauseXlet() {
    }

    public void destroyXlet(boolean flag) throws XletStateChangeException {
        if (scene != null) {
            scene.setVisible(false);
            scene.removeAll();
            scene = null;
        }
        context.notifyDestroyed();
    }
    
    private void updateList(List list){  
    	list.removeAll();    
    	ServiceList collection = 		
    		si_manager.filterServices(null);    
    	ServiceIterator si = 		
    		collection.createServiceIterator();    
    	si.toEnd();    
    	if(list == slist) {      
    	    while(si.hasPrevious()){        
    		slist.addItem(	si.previousService().getName(), 0);      
    	    }    
    	} else {      
    	    while(si.hasPrevious()){         
    		Service s = si.previousService();        
    		if(slist.getSelectedItem().equals(s.getName())) {          	
    		       retriever.getPrograms(s);          
    			break;        
    		}      
    	    }     
    	}  
    }
    
    public void actionPerformed(ActionEvent evt){    
    	if(evt.getSource() == button){      
    		this.updateList(slist);      
    		plist.removeAll();    
    	} else if (evt.getSource() == slist) {      
    		this.updateList(plist);    
    	}   
    }	

    public void keyTyped(KeyEvent e) {
    }

    public void keyReleased(KeyEvent e) {
    }

    public void keyPressed(KeyEvent e) {
        ServiceList collection = null;    
        Service s = null;
        ServiceIterator si = null;
        int indexSelect = -1;
        
        switch(e.getKeyCode()) {
       		case '1': 
       		case KeyEvent.VK_NUMPAD1: 
       			System.out.println("code 1");
       			
       			collection = 		
       				si_manager.filterServices(null);
       			
       			if(collection.size() > 0) {
	       			s = collection.getService(0);
	       			slist.select(0);          	
	       			plist.removeAll();
	       			retriever.getPrograms(s);          
       			}
              break;
              // análogo para as demais teclas numéricas KEY_UP e KEY_DOWN são            
                 // implementadas para ir selecionando o próximo item da lista
         }
    }
}
// NOVA CLASSE

import java.text.DateFormat;
import java.util.Date;

import xjavax.tv.service.*;
import xjavax.tv.service.guide.ProgramEvent;
import xjavax.tv.service.navigation.ServiceDetails;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import org.havi.ui.*;


class Retriever implements SIRequestor {    
	DateFormat dfmt = DateFormat.getDateInstance(DateFormat.SHORT);    
	DateFormat tfmt = DateFormat.getTimeInstance(DateFormat.SHORT);    
	
	void getPrograms(Service s) {      
	   try{	
		   
		si_manager.retrieveServiceDetails(s.getLocator(), this);      
	   } catch (Exception e) {         
		e.printStackTrace();       
	   }    
	}    	
	public void notifySuccess(SIRetrievable[] result) {      
 	   if(result[0] instanceof ServiceDetails) {
		try{          
 		((ServiceDetails)result[0]).getProgramSchedule().
		   retrieveFutureProgramEvents(new Date(),
			new Date(System.currentTimeMillis() + 600000000), this);          
 		} catch (SIException e) {}      
 	   } else if (result[0] instanceof ProgramEvent) {      
		for(int i = 0; i < result.length; i++ ) {           
 		    ProgramEvent e = (ProgramEvent)result[i];
 		    StringBuffer s = new StringBuffer();
 		    
 		    plist.addItem(e.getName() + " : " + dfmt.format(e.getStartTime()) 				
                   + " " +               tfmt.format(e.getStartTime()));        
 		}      
 	   }    
 	}	

	public void notifyFailure(SIRequestFailureType arg0) {
		// TODO Auto-generated method stub
		
	}


}

Erro
[code]
free/used/total: 1088 K / 3303 K / 4392 K
running gc...
after gc...
free/used/total: 2504 K / 2887 K / 5392 K
[XleTView]-INFO->loading Xlet... [bin.FirstXletExample]
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: bin/FirstXletExample (wrong name: FirstXletExample)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at net.beiker.xletview.classloader.MainClassLoader.findClass(Unknown Source)
at net.beiker.xletview.classloader.EmulatorClassLoader.findClass(Unknown Source)
at net.beiker.xletview.classloader.EmulatorClassLoader.loadClass(Unknown Source)
at net.beiker.xletview.classloader.XletClassLoader.loadClass(Unknown Source)
at net.beiker.xletview.xlet.XletManager.runXlet(Unknown Source)
at net.beiker.xletview.xlet.XletManager.setXlet(Unknown Source)
at net.beiker.xletview.ui.AppMenu.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)[/color]

Obs importante: utilizo como Ide o Eclipse Europa
Quem pudre me ajudar por favor !!!
Desde já Obrigado! abração para todos!

Criado 19 de outubro de 2007
Respostas 0
Participantes 1