Skip to main content

LWUIT

5 replies [Last post]
heziflash
Offline
Joined: 2008-06-03
Points: 0

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
heziflash
Offline
Joined: 2008-06-03
Points: 0

Thanks Chen. It is working.

heziflash
Offline
Joined: 2008-06-03
Points: 0

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
Offline
Joined: 2008-04-29
Points: 0

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...
Offline
Joined: 2008-06-03
Points: 0

LWUIT is the bomb.

chenf
Offline
Joined: 2008-04-29
Points: 0

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