The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: LWUIT

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Jun 9, 2008 6:48 AM by: heziflash
heziflash

Posts: 77
LWUIT
Posted: Jun 3, 2008 8:34 AM
 
  Click to reply to this thread Reply

Hi
I started to work with LWUIT.
I put some png files on my cellular phone and i want to select one of them , with UP, DOWN, LEFT, RIGHT.
How can i do it?

TIA
Hezi

chenf

Posts: 34
Re: LWUIT
Posted: Jun 3, 2008 9:10 AM   in response to: heziflash
 
  Click to reply to this thread Reply

Hi Hezi,
I didn't quite understand what are you asking, can you share more info?
Are you trying to create some sort of a File browser?

Thanks,
Chen

heziflash

Posts: 77
Re: LWUIT
Posted: Jun 4, 2008 11:57 PM   in response to: heziflash
 
  Click to reply to this thread Reply

Hi Chen

My qustion is very basic.

I build a menu wtih LWUIT:
public void startApp() {
Display.init(this);

final Form f = new Form("Hello, LWUIT!");
Label label = new Label("Baldy");
f.addComponent(label);
try {

Image image = Image.createImage("/res/duke.png");
Image image1 = Image.createImage("/res/Animations_sel.png");

Label pictureLabel = new Label(image);
f.addComponent(pictureLabel);

Label pictureLabel1 = new Label(image1);
f.addComponent(pictureLabel1);

.
.
.
This work ok.
Now, I want to select btween image1 and image (something like:
void handleActions(int keyCode) {
int action = getGameAction(keyCode);
switch (action) {
case LEFT:
x -= 1;
break;
case RIGHT:
x += 1;
break;
case UP:
y -= 1;
break;
case DOWN:
y += 1;
break;
}
}
)
but in a LWUIT way - means: to write the code in actionPerformed(ActionEvent ae)
second, I want the selected image to ZOOM IN or to change color so i can see the choosem image.
How can I do it?

TIA
Hezi

chenf

Posts: 34
Re: LWUIT
Posted: Jun 5, 2008 2:03 AM   in response to: heziflash
 
  Click to reply to this thread Reply

Hi Hezi,

Labels by default doesn't grab focus, to enable focus on Labels you need to call:

Label.setFocusable(true);

Regarding the second part of your question about events:

If you want to preform some action when the user clicks on the images, you might want to us a Button instead of a Label.
You can Choose to draw the button without borders if you prefer the "Label look" by calling to Button.setBorderPainted(false), then add your action on the button by using
Button.addActionListener(ActionListener l), the listener code will be invoked when the user clicks on the FIRE key.

Regards,
Chen

d_unicorn_techn...

Posts: 1
Re: LWUIT
Posted: Jun 5, 2008 9:58 AM   in response to: chenf
 
  Click to reply to this thread Reply

LWUIT is the bomb.

heziflash

Posts: 77
Re: LWUIT
Posted: Jun 9, 2008 6:48 AM   in response to: heziflash
 
  Click to reply to this thread Reply

Thanks Chen. It is working.




 XML java.net RSS