Pessoal tenho o seguinte midlet de teste…
import com.sun.lwuit.CheckBox;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Display;
import com.sun.lwuit.Command;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.geom.Dimension;
import com.sun.lwuit.plaf.Border;
import com.sun.lwuit.plaf.Style;
import com.sun.lwuit.plaf.UIManager;
import javax.microedition.midlet.MIDlet;
public class DemoCheckBox extends MIDlet implements ActionListener
{
private final int cbQty = 6;//number of checkboxes
private CheckBox[] checkboxes = new CheckBox[cbQty];
//if true all selections will be cleared on return from dialog
private boolean reset;
public void startApp()
{
//initialize the LWUIT Display
//and register this MIDlet
Display.init(this);
//create a new form
Form demoForm = new Form("CheckBox Demo");
//create a font
Font font = Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD,Font.SIZE_LARGE);
//set text color for title
demoForm.getTitleStyle().setFgColor(0xffffff);
//set font style for title
demoForm.getTitleStyle().setFont(font);
//set background color for the title bar
demoForm.getTitleStyle().setBgColor(0xff8040);
//create a new style object
Style menuStyle = new Style();
//set the background color -- the same as for title bar
menuStyle.setBgColor(0xff8040);
//set the text color for soft button
menuStyle.setFgColor(0xffffff);
//set font style for soft button
menuStyle.setFont(font);
//now install the style for soft button
demoForm.setSoftButtonStyle(menuStyle);
//set a background color for the form
demoForm.getStyle().setBgColor(0x656974);
//make the content pane fully transparent
demoForm.getContentPane().getStyle().setBgTransparency(0);
//create and add 'Exit' command to the form
//the command id is 0
demoForm.addCommand(new Command("Exit", 0));
demoForm.addCommand(new Command("Confirm", 1));
//this MIDlet is the listener for the form's command
demoForm.setCommandListener(this);
//create a style for labels
Style labelStyle = new Style();
labelStyle.setBgTransparency(0);
labelStyle.setFgColor(0x00ffff);
labelStyle.setFont(font);
labelStyle.setMargin(Label.BOTTOM, 30);
//set the style for all labels
UIManager.getInstance().setComponentStyle("Label", labelStyle);
//create a label to explain the purpose of the checkboxes
Label expLabel = new Label("Select all languages known");
//add the label to the form
demoForm.addComponent(expLabel);
//create font for checkboxes
Font cbFont = Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
//create a style for checkboxes
Style cbStyle = new Style();
cbStyle.setBgTransparency(64);
cbStyle.setFgColor(0x00ffff);
//cbStyle.setFgSelectionColor(0x00ff00);
cbStyle.setBgColor(0x999900);
//cbStyle.setBgSelectionColor(0xaa0000);
cbStyle.setFont(cbFont);
cbStyle.setBorder(Border.createEtchedRaised());
cbStyle.setMargin(Label.BOTTOM, 10);
//set the style for all checkboxes
UIManager.getInstance().setComponentStyle("CheckBox", cbStyle);
//strings for checkbox texts
String[] langs = {"Chinese", "Spanish", "English", "Portuguese", "Hindi", "Bengali"};
//preferred dimensions for checkboxes
Dimension d1 = new Dimension(100, 25);
//create six checkboxes and add them to the form
for(int i = 0; i < cbQty; i++)
{
//create a checkbox
checkboxes[i] = new CheckBox(langs[i]);
//set its preferred size
checkboxes[i].setPreferredSize(d1);
//set right margin for first, third and fifth checkboxes
//this is to provide a gap between the two columns of checkboxes
//and is a device specific approach
if(i % 2 == 0)
{
checkboxes[i].getStyle().setMargin(Label.RIGHT, 15);
}
//add checkbox to form
demoForm.addComponent(checkboxes[i]);
}
//set border for form title bar
demoForm.getTitleStyle().setBorder(Border.createBevelRaised());
//set border for form menu bar
demoForm.getSoftButtonStyle().setBorder(Border.createBevelLowered());
//show the form
demoForm.show();
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
//act on the command
public void actionPerformed(ActionEvent ae)
{
Command cmd = ae.getCommand();
switch (cmd.getId())
{
//'Exit' command
case 0:
notifyDestroyed();
break;
//'Confirm' command
case 1:
//call method to display dialog
showDialog();
//on retun from showDialog method
//check whether reset is true
if(reset)
{
//it's true, first set reset to false
//to make it ready for next time
reset = false;
//check each checkbox
for(int i = 0; i < cbQty; i++)
{
//check its state
if(checkboxes[i].isSelected())
{
//it's selected so clear it
checkboxes[i].setSelected(false);
}
}
}
}
}
private void showDialog()
{
int j = 0;
//dimension of labels to display selections
Dimension dim = new Dimension(100, 25);
//create the dialog
Dialog d = new Dialog("Selection");
//give it a border
d.getContentPane().getStyle().setBorder(Border.createBevelRaised());
//font for the labels
Font f = Font.createSystemFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
//create labels as required
for(int i = 0; i < cbQty; i++)
{
//see if a checkbox is selected
if(checkboxes[i].isSelected())
{
//it is selected so create a label to show its text
Label l = new Label(checkboxes[i].getText());
//set preferred size of the label
l.setPreferredSize(dim);
//set color for the text on labels
l.getStyle().setFgColor(0x555555);
//set font for the text on labels
l.getStyle().setFont(f);
//set a small botom margin
//again, this is a device specific action
l.getStyle().setMargin(Label.BOTTOM, 5);
//add the label to the form
d.addComponent(l);
}
}
//set bg color for dialog
d.getContentPane().getStyle().setBgColor(0xff8040);
//set style attributes for the dialog titlebar
d.getTitleStyle().setBgColor(0xa43500);
d.getTitleStyle().setFgColor(0xffffff);
d.getTitleStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM));
d.getTitleStyle().setBorder(Border.createBevelRaised());
//create and set style for dialog menubar
Style s = new Style();
s.setBgColor(0xa43500);
s.setFgColor(0xffffff);
s.setFont(Font.createSystemFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM));
s.setBorder(Border.createBevelRaised());
d.setSoftButtonStyle(s);
//add two commands to dialog
d.addCommand(new Command("OK"));
d.addCommand(new Command("Back"));
//show the dialog
//this method will return the command selected when dialog is closed
Command cmd = d.showDialog();
//check the command name
if(cmd.getCommandName().equals("OK"))
{
//it's 'OK' command so set reset to true
//so that all selections can be cleared
reset = true;
}
}
}
[b]Quando eu tento rodar da o seguinte erro
Running with storage root C:\Users\emerson\j2mewtk\2.5.2\appdb\DefaultColorPhone
Running with locale: Portuguese_Brazil.1252
Running in the identified_third_party security domain
java.lang.NoClassDefFoundError: DemoCheckBox: com/sun/lwuit/events/ActionListener
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.[/b]
Alguém sabe como resolver?