Set Icon in Button LWUIT Java ME
Posted
by
Muhamad Burhanudin
on Stack Overflow
See other posts from Stack Overflow
or by Muhamad Burhanudin
Published on 2012-06-16T08:56:01Z
Indexed on
2012/06/16
9:16 UTC
Read the original article
Hit count: 320
java
|lwuit-button
Please help me, to set icon button :
/*
* To change this template, choose Tools | Templates * and open the template in the editor. */ package tajwed;
import javax.microedition.midlet.*;
import com.sun.lwuit.*;
import com.sun.lwuit.animations.*;
import com.sun.lwuit.events.*;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.*;
import java.io.IOException;
import java.util.Hashtable;
/** * @author Muhamad BUrhanudin */ public class tajwedMidlet extends MIDlet implements ActionListener{
Form mHomeForm;
Form mAwayForm;
Form mMenuTajwid;
Command mExitCommand;
Button btMenu;
Button btNunSukun, btMimSukun, btNunTasjid;
Button btLamtarif, btIdgham, btMaad, btRaa;
Button btHelp;
Button btExit;
Command mBackCommand;
public void startApp() {
Display.init(this);
installTheme();
createUI();
mHomeForm.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void actionPerformed(ActionEvent ae)
{
mAwayForm.setTransitionInAnimator(
Transition3D.createCube(400, false));
mMenuTajwid.setTransitionInAnimator(
Transition3D.createCube(400, false));
mMenuTajwid.setTransitionOutAnimator(
Transition3D.createCube(400, true));
mAwayForm.setTransitionOutAnimator(
Transition3D.createCube(400, true));
if ((ae.getSource()==btMenu)|| (ae.getSource()==btHelp))
{
//mAwayForm.show();
if(ae.getSource()== btMenu)
{
mMenuTajwid.show();
}
}
else if (ae.getSource() == mBackCommand) {
mHomeForm.show();
}
else if ((ae.getCommand() == mExitCommand) || (ae.getSource()== btExit))
notifyDestroyed();
}
private void installTheme()
{
UIManager uim = UIManager.getInstance();
Hashtable ht = new Hashtable();
ht.put("sel#" + Style.BG_COLOR, "ffffff");
ht.put(Style.BG_COLOR, "d5fff9");
ht.put(Style.FG_COLOR, "000000");
uim.setThemeProps(ht);
}
private void createUI() {
// Set up screen for transitions.
mAwayForm = new Form("Away");
mAwayForm.addComponent(new Label("Choose Back to return to the home screen."));
mMenuTajwid = new Form("MENU DASAR TAJWID");
// mMenuTajwid
mMenuTajwid.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
btNunSukun = new Button("Hukum Nun Sukun & Tanwin");
btNunSukun.addActionListener(this);
mMenuTajwid.addComponent(btNunSukun);
btMimSukun = new Button("Hukum Mim Sukun");
btMimSukun.addActionListener(this);
mMenuTajwid.addComponent(btMimSukun);
btNunTasjid = new Button("Hukum Nun Tasydid & Min Tasydid");
btNunTasjid.addActionListener(this);
mMenuTajwid.addComponent(btNunTasjid);
btLamtarif = new Button("Hukum Laam Ta'rief");
btLamtarif.addActionListener(this);
mMenuTajwid.addComponent(btLamtarif);
btIdgham = new Button("Idgham");
btIdgham.addActionListener(this);
mMenuTajwid.addComponent(btIdgham);
btMaad = new Button("Maad");
btMaad.addActionListener(this);
mMenuTajwid.addComponent(btMaad);
btRaa = new Button("Raa'");
btRaa.addActionListener(this);
mMenuTajwid.addComponent(btRaa);
mBackCommand = new Command("Back");
mMenuTajwid.addCommand(mBackCommand);
mMenuTajwid.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
// Set up main screen.
mHomeForm = new Form("Java Mobile Learning");
mHomeForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
btMenu = new Button("TAJWID LEARNING");
btMenu.addActionListener(this);
mHomeForm.addComponent(btMenu);
try
{
btHelp = new Button("HELP",Image.createImage("/help.ico"));
btHelp.addActionListener(this);
mHomeForm.addComponent(btHelp);
}
catch(IOException e)
{
}
btExit = new Button("EXIT");
btExit.addActionListener(this);
mHomeForm.addComponent(btExit);
mExitCommand = new Command("Keluar");
mHomeForm.addCommand(mExitCommand);
mHomeForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
}
}
© Stack Overflow or respective owner