Skip to main content

Focus issue

5 replies [Last post]
harsha973
Offline
Joined: 2010-05-05
Points: 0

Hi,

I'm working on basic focus for HTextButton.I used the following code.

HTextButton textButtonTest=new HTextButton("event 2",150,150,70,70);
textButtonTest.setVisible(true);
textButtonTest.addHActionListener(this);
textButtonTest.addHFocusListener(this);
textButtonTest.setBackground(Color.BLUE);
textButtonTest.setForeground(Color.WHITE);
textButtonTest.setBackgroundMode(HVisible.BACKGROUND_FILL);
textButtonTest.setFocusable(true);
//adding to HScene
m_scene.add(textButtonTest);

I checked debugging the file textButtonTest.isFocusable() returning true.I'm able to view the button but i'm not able to get Focus on Button.

When i'm running the application I'm getting some Info about permissions like this...

INFO RI.Stack - 12672 [pool-4] INFO security.Policy - Permissions for (0 file:/D/eclipseworkspace/HelloWorldApp/bin/ ) are org.cablelabs.impl.security.AppPermissions@c445860c( (org.ocap.application.OcapIxcPermission /service-*/unsigned/*/*/* lookup)
(org.ocap.application.OcapIxcPermission /service-2/unsigned/0/0/* bind)
(java.net.SocketPermission localhost connect,listen,accept,resolve)
(javax.tv.service.selection.ServiceContextPermission access own)
(javax.tv.service.selection.ServiceContextPermission getServiceContentHandlers own)
(javax.tv.media.MediaSelectPermission *)
(java.io.FilePermission /oc/- read)
(org.ocap.shared.dvr.RecordingPermission read own)
(java.util.PropertyPermission mhp.ia.version.* read)
(java.util.PropertyPermission gem.recording.version.micro read)
(java.util.PropertyPermission gem.recording.version.minor read)
(java.util.PropertyPermission mhp.profile.* read)
(java.util.PropertyPermission havi.specification.name read)
(java.util.PropertyPermission INFO RI.Stack - 12735 [pool-4] INFO application.Application$State - appid=0 ~AUTO_PARTIALLY_LOADED->LOADED success.

Can any one tell me how to acess this permissions.

Thanks in advance,
Sree Harsha.P

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
david_crandall
Offline
Joined: 2010-01-05
Points: 0

Small mention here: 'show()' is depricated. Use setVisible(true);

greg80303
Offline
Joined: 2008-07-03
Points: 0

The permission-related logs you refer to are actually showing the set of permissions that have been granted to your application -- it is not a permission error.

In order to acquire the focus, the HScene must be both "visible" and "active". Make sure you are calling HScene.show(), and HScene.setActive(true). Also, make sure you are calling Component.requestFocus() on the component that you wish to have focus. You can also just call HScene.requestFocus() if you only have the one component present in your scene.

G

harsha973
Offline
Joined: 2010-05-05
Points: 0

Thanks for reply,

I used Component.requestFocus() and Hscene.setActive(true).I'm already using Hscene.Show().I'm able to get the display and the content i want to display.But I'm not getting focus and not generating Event .The code is as follows

textButton.setVisible(true);
textButton.addHActionListener(this);
textButton.addHFocusListener(this);
textButton.setBackground(Color.BLUE);
textButton.setForeground(Color.WHITE);
textButton.setBackgroundMode(HVisible.BACKGROUND_FILL);
textButton.setBordersEnabled(true);
textButton.setFocusable(true);
textButton.requestFocus();
m_scene.add(textButton);

m_scene.setFocusable(true);
m_scene.setActive(true);

m_scene.show();
m_scene.repaint();

So,I'm not getting where the problem lies.
I'm using OCAP RI as suggested in IBM website.

http://www.ibm.com/developerworks/java/library/j-ocap1/index.html?ca=drs-

http://www.ibm.com/developerworks/java/library/j-ocap2/index.html?ca=drs-

I'm using OCAP plugin for Eclipse.Is it the OCAP RI used by you?.Or should i have to use another OCAP RI?.Any one suggest.

Thanks in Advance,
Harsha

david_crandall
Offline
Joined: 2010-01-05
Points: 0

Just taking a wild-guess here, try requesting the focus after you add the text button to the scene.

Mechanically, that makes more sense than anything, but I don't see anything terribly obvious.

greg80303
Offline
Joined: 2008-07-03
Points: 0

Yes, David -- this is important. According to OCAP focus rules (OCAP1.1.3 section 25.2.2.1.1), in order for an HScene to be eligible to receive the focus, it must be both active and visible. The OCAP spec calls this HScene "activable". So, as David suggested, make sure you call request focus after you have called HScene.setActive(true) and HScene.setVisible(true).

G