Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Drop down redirect?

[ Edited ]

Your application has to extends UiApplication class.

 

enterEventDispatcher() is not inside of MainScreen class.

 

It defined in UiApplication and into Application classes.

 

Check javadoc before use of methods.

 

It will avoid such errors in future.

 

And check this link: http://www.devx.com/wireless/Article/27869/1954

Message Edited by tbilisoft on 21-12-2008 06:43 PM
Please use plain text.
Developer
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Drop down redirect?

Thanks for all your help, I'm throwing in the towel though. I've spent too many hours on creating just a simple drop down. I guess I will just stick to what I know which unforentually isn't java.

 

Thanks again for all your help

 

Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Drop down redirect?

[ Edited ]

Create this simple application following to that link and extend it with necessary functionality.

 

Also check this link for a sample bb application:

 

http://java-blackberry.blogspot.com/2008/02/developing-applications-using-jde.html

Message Edited by tbilisoft on 21-12-2008 07:14 PM
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Drop down redirect?

[ Edited ]

 

You say: I wish there were more sample code on the net though

 

...what is wrong with the sample applications shipped with the JDE? There are about 40 of them. You will be well served by spending some time on these samples, starting with HelloWorld.

 

 

 

 

Message Edited by RexDoug on 12-21-2008 01:48 PM
Please use plain text.
Developer
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Drop down redirect?

[ Edited ]
Okay I slept on it, read a ton of tutorials, watched some tutorials and I finally got it working.

 

Now I'm trying to setup a textfield with a KeyListener. When the user hits enter I want to get the value of what's in the textfield and do something with the value. Can you guys tell me if I'm on the right pathat all? I really tried to google my way around this one. I've also spent quite a bit of time looking at the 4.7 jde reference. I'm not able to get it though.

//Constructs the textfield class TextConst extends MainScreen implements KeyListener { private TextField testField = new TextField(); public TextConst(){ super(); addKeyListener(this); } public boolean keyChar( char key, int status, int time ){ if(key == Characters.ENTER){ //User hit enter do something with the code } } public boolean keyDown(int keycode, int time){ return false; } public boolean keyRepeat(int keycode, int time){ return false; } public boolean keyStatus(int keycode, int time){ return false; } public boolean keyUp(int keycode, int time){ return false; } }

 

Message Edited by dmglakewood on 12-22-2008 07:45 AM
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Drop down redirect?

This is the wrong approach.

 

Override keyChar() in your Screen class:

protected boolean keyChar(char c, int status, int time) { switch(c){ case Characters.ENTER: // do something to the fieldhere return true; } return super.keyChar(c,status,time); }

 

 

Or, add a FieldListener to the text field.

 

You can figure out which field has the focus in your keyCar() method using getFieldWithFocus();

 

You probably will also need to override navigationClick()

Please use plain text.
Developer
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Drop down redirect?

[ Edited ]

RexDoug wrote:

This is the wrong approach.

 

Override keyChar() in your Screen class:

protected boolean keyChar(char c, int status, int time)
{
switch(c){

case Characters.ENTER:
// do something to the fieldhere
return true;
}

return super.keyChar(c,status,time);
}

 

 

Or, add a FieldListener to the text field.

 

You can figure out which field has the focus in your keyCar() method using getFieldWithFocus();

 

You probably will also need to override navigationClick()


Man just when I thought I was getting the hang of it. I can't seem to find too much on keyChar but I will keep looking. It keeps spitting out all kinds of errors, I must have it in the wrong location?
This is what my TextConst.java looks like

package sgWallpapers.TextConst;

import net.rim.device.api.system.*;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;


//Main Class
class TextConst extends UiApplication {

public static void main(String args[]){
TextConst testText = new TextConst();
testText.enterEventDispatcher();
}

public TextConst(){
TextMain textScreen = new TextMain();
pushScreen(textScreen);
}
}


//Constructs the textfield
class TextMain extends MainScreen implements KeyListener {
private TextField testField = new TextField();

protected boolean keyChar(char c, int status, int time){
switch(c){
case Characters.ENTER:
// do something to the fieldhere
return true;
}
return super.keyChar(c,status,time);
}

public TextMain(){
super();

}
}

 

 

Message Edited by dmglakewood on 12-22-2008 08:53 AM
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Drop down redirect?

Get rid of "extends KeyListener" - this will now generate errors for each of the KeyListener methids that you are not implementing.
Please use plain text.
Developer
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Drop down redirect?

Okay I got everything working now. For some reason it didn't like the fact that I had it in two files. I intergrated it into 1 large file and it works just fine.

 

 

Anyways my TextField is there but I can't see it. Is there a way to put a border around it or something?

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,241
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Drop down redirect?

You can use the new decor APIs added in version 4.6.0 to add borders around fields or managers.  Have a look at the decordemo included with the BlackBerry JDE for an example.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.