Skip to main content

ArithmeticException occur when I use theming

7 replies [Last post]
godpig
Offline
Joined: 2009-02-19

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
godpig
Offline
Joined: 2009-02-19

oh, I'm very sorry, The code above I have posted is so chaotic.

pakmee
Offline
Joined: 2008-09-01

try loading the resources first before doing anything just after u declare display.init(this)

godpig
Offline
Joined: 2009-02-19

Yeah, I have tried
But the same error occur

The critical code is the Container class and TabbedPane class

It works if I am not use the TabbedPane too

The three conditions are satisfied, there are must be an error:
1) Use the theming
2) Use the Container
3) Add Container as a tab to TabbedPane

thank you!

Best Regards

Message was edited by: godpig

godpig
Offline
Joined: 2009-02-19

Now, I have resoved it!
I change the function of timeModify()

private void timeModify() {
// TODO Auto-generated method stub
Form f = new Form();
f.setLayout(new BorderLayout());
f.setScrollable(false);
final TabbedPane tp = new TabbedPane();

tp.addTab("Tab 1", new Label("Welcome to TabbedPane demo!"));

//Container radioButtonsPanel = new Container(new BoxLayout(BoxLayout.Y_AXIS));
Container tm = new Container(new BoxLayout(BoxLayout.Y_AXIS));
tm.addComponent(new Label("Time set:"));
tp.addTab("Tab 2", tm);

f.addComponent("Center", tp);

f.addCommand(cExit);
f.addCommand(cOK);
f.setCommandListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
Command cmd = evt.getCommand();
if (cmd == cExit) {
//f = null;
mainForm.show();
return;
} else if (cmd == cOK) {
}
}

});

f.show();

System.gc();
}

It runs ok.
the different is:
f.addComponent("Center", tp);
when I add the center borderlayout, everything is ok!

godpig
Offline
Joined: 2009-02-19

the final result is that I use Serif font which doesn't support chinese!

I delete the Font style in resources, It ok now

thanks all of you!

Shai Almog

Hi,
no we didn't see this.
Are you using the current SVN?
Did you set the list item gap to 0?

If so can you please provide code to reproduce the issue?

Feel free to open an issue for this.

> Hi,all
> I work good if I am not use theming, but if I use it by resources
> and switch one form to another by transition,this error will be
> appear
>
> these messages are appear in eclipse:
>
> java.lang.ArithmeticException
> at com.sun.lwuit.List.pointerSelect(+318)
> at com.sun.lwuit.List.paint(+275)
> at com.sun.lwuit.Component.paintInternal(+135)
> at com.sun.lwuit.Container.paint(+49)
> at com.sun.lwuit.TabbedPane.paint(+5)
> at com.sun.lwuit.Component.paintInternal(+135)
> at com.sun.lwuit.Container.paint(+49)
> at com.sun.lwuit.Component.paintInternal(+135)
> at com.sun.lwuit.Container.paint(+49)
> at com.sun.lwuit.Form.paint(+10)
> at com.sun.lwuit.Component.paintInternal(+135)
> at com.sun.lwuit.Component.paintInternal(+6)
> at com.sun.lwuit.Component.paintComponent(+246)
> at com.sun.lwuit.Component.paintComponent(+6)
> at com.sun.lwuit.impl.LWUITImplementation.paintDirty(+197)
> at com.sun.lwuit.Display.edtLoopImpl(+142)
> at com.sun.lwuit.Display.mainEDTLoop(+153)
> at com.sun.lwuit.Display$1.run(+6)
> Uncaught exception java/lang/ArithmeticException.
>
> Is there anybody encountered this?
>
> thanks very much!
> [Message sent by forum member 'godpig' (godpig)]
>
> http://forums.java.net/jive/thread.jspa?messageID=333041
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/
https://lwuit.dev.java.net/faq.html

[att1.html]

godpig
Offline
Joined: 2009-02-19

Yes,thank you

I have found the code which result the error!

The follow two snippets explore this:

code:
public class HelloLwuit extends javax.microedition.midlet.MIDlet {

Command ee = new Command("test", 1);
Command bk = new Command("back", 1);
Form mainForm;//, f2;

public void startApp() {
// init the LWUIT Display
Display.init(this);

mainForm = new Form();
mainForm.setTitle("Hello World");
mainForm.setLayout(new BorderLayout());

mainForm.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 500));
mainForm.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 500));

mainForm.addCommand(ee);

mainForm.setCommandListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
timeModify();
}

});

mainForm.show();
/**/
try {
Resources r = Resources.open("/javaTheme.res");
UIManager.getInstance().setThemeProps(
r.getTheme("javaTheme"));
Display.getInstance().getCurrent().refreshTheme();
} catch (java.io.IOException e) {
System.out.println("Error Occur when Load res");
}
/**/
}

private static final int EXIT_COMMAND = 1;
private static final int OK_COMMAND = 2;
private static final Command cOK = new Command("OK", OK_COMMAND);
private static final Command cExit = new Command("Exit", EXIT_COMMAND);

private void timeModify() {
// TODO Auto-generated method stub
Form f;
f = new Form();

TabbedPane tp = null;
tp = new TabbedPane();
/**/
Container tm = new Container(new BoxLayout(BoxLayout.Y_AXIS));
tm.addComponent(new Label("time setting:"));
tp.addTab("tab1", tm);
/*/
tp.addTab("tab1", new Label("this is label1"));
tp.addTab("tab2", new Label("this is label2"));
//*/

f.addComponent(tp);

f.addCommand(cExit);
f.addCommand(cOK);
f.setCommandListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
Command cmd = evt.getCommand();
if (cmd == cExit) {
mainForm.show();
return;
} else if (cmd == cOK) {

}
}

});

f.show();

System.gc();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}

The critical code is:
/**/ //btw: Add one space after the second *, you can make the code2 snippet valid

//This code is code1
Container tm = new Container(new BoxLayout(BoxLayout.Y_AXIS));
tm.addComponent(new Label("time setting:"));
tp.addTab("tab1", tm);
/*/
//This code is code2
tp.addTab("tab1", new Label("this is label1"));
tp.addTab("tab2", new Label("this is label2"));
//*/

If I use Container class, the error will be occur, if I not, It run ok
There is something wrong in my code?

Best Regards!