Skip to main content

JavaME with TotalMedia Theatre player

2 replies [Last post]
dbirchfield
Offline
Joined: 2009-10-04

Hi all,

I have Java experience, but am a newbie to BD-J, so thank you in advance for your help. I'm using the JavaME 3.0 tools to compile a test Xlet application. Then attempting to run the code via Total Media Theatre. The code is simply the default code generated by JavaME, so there isn't anything fancy going on.

However, when I attempt to run the code I'm getting the error that is copied below, despite the fact that I'm not trying to do any thing with the keyboard.

I've found mention of this error previously, but only an inconclusive mention that perhaps it is a bug with the player? Have others experienced this too?

Thank you again!
David

Here is my code:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Font;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;

/**
* @author dab
*/
public class BDJInput implements javax.tv.xlet.Xlet {

//private static Font font;
private HScene scene;
private Container gui;
private static final String message = "Hello BD-J World!";
private Font font;

/**
* Default constructor without arguments should be.
*/
public BDJInput() {
}

/**
* Put your initialization here, not in constructor.
* If something goes wrong, XletStateChangeException
* should be thrown.
*/
public void initXlet(javax.tv.xlet.XletContext context)
throws javax.tv.xlet.XletStateChangeException {

font = new Font(null, Font.PLAIN, 48);

scene = HSceneFactory.getInstance().getDefaultHScene();
scene.setBackground(Color.green);

gui = new Container() {
public void paint(Graphics g) {
g.setFont(font);
g.setColor(new Color(255, 10, 10));
g.fillRect(20, 20, getWidth() - 40, getHeight() - 40);
g.setColor(new Color(245, 245, 245));
int message_width = g.getFontMetrics().stringWidth(message);
g.drawString(message, (getWidth() - message_width) / 2, 500);
}

};

gui.setSize(1920, 1080); // BD screen size

scene.add(gui, BorderLayout.CENTER);
scene.add(gui);

scene.validate();
}

/**
* Xlet will be started here.
* If something goes wrong, XletStateChangeException
* should be thrown.
*/
public void startXlet() throws javax.tv.xlet.XletStateChangeException {
gui.setVisible(true);
scene.setVisible(true);
}

/**
* Free resources, stop unnecessary threads, remove
* itself from the screen.
*/
public void pauseXlet() {
gui.setVisible(false);
}

/**
* Destroy yout xlet here.
* If parameter is false, you can try to not destroy xlet
* by throwing an XletStateChangeException
*/
public void destroyXlet(boolean unconditional)
throws javax.tv.xlet.XletStateChangeException {
scene.remove(gui);
scene = null;
}
}

Here is the error:

[14:29:47.515] [error] Exception occurred during event dispatching:
[14:29:47.515] [error] java.lang.SecurityException: this KeyboardFocusManager is not installed in the current thread's context
[14:29:47.515] [error] at java.awt.KeyboardFocusManager.getGlobalActiveWindow(KeyboardFocusManager.java:350)
[14:29:47.515] [error] at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:221)
[14:29:47.515] [error] at java.awt.Component.dispatchEventImpl(Component.java:2099)
[14:29:47.515] [error] at java.awt.Window.dispatchEventImpl(Window.java:281)
[14:29:47.515] [error] at java.awt.Component.dispatchEvent(Component.java:2090)
[14:29:47.515] [error] at java.awt.EventQueue.dispatchEvent(EventQueue.java:284)
[14:29:47.515] [error] at java.awt.EventQueueProxy.dispatchEvent(EventDispatchThread.java:286)
[14:29:47.515] [error] at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:98)
[14:29:47.515] [error] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
[14:29:47.515] [error] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:83)
[14:29:47.515] [error] at java.awt.EventDispatchThread.run(EventDispatchThread.java:74)
[14:29:47.515] [error] at java.lang.Thread.startup(Thread.java:775)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vinaykagarwal
Offline
Joined: 2006-01-14

It is a harmless TMT bug - I get it all the time and just ignore it.

chihiro_saito
Offline
Joined: 2006-11-08

Hi David,

This error is probably a known TMT issue, since I've been seeing it often during my testing as well. The apps seem to run fine even with this exception for me. So if your application is not working, then perhaps you have another exception somewhere in the log?

Chihiro