gpt4 book ai didi

java - 更新后 codename1 NullPointerException

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:33 25 4
gpt4 key购买 nike

项目设置更新后,我收到此 NullPointerException[EDT] 0:0:0,0 - 代号一修订:e5578786e9d343acce705b819a37288d29591b72

[EDT] 0:0:0,71 - 异常:java.lang.NullPointerException - nulljava.lang.NullPointerException 在 com.codename1.ui.SideMenuBar$CommandWrapper.actionPerformed(SideMenuBar.java:1788) 在 com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349) 在 com.codename1.ui.Button.fireActionEvent(Button.java:491) 在 com.codename1.ui.Button.released(Button.java:533) 在 com.codename1.ui.Button.pointerReleased(Button.java:637) 在com.codename1.ui.Form.pointerReleased(Form.java:2807) 在 com.codename1.ui.Component.pointerReleased(Component.java:4016) 在 com.codename1.ui.Display.handleEvent(Display.java:2032) 在 com.codename1.ui.Display.edtLoopImpl(Display.java:1028) 在 com.codename1.ui.Display.mainEDTLoop(Display.java:946) 在 com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120) 在 com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

代号one中似乎有一些东西。有谁知道怎么处理吗?

编辑。

好的@Shai,我想我找到了为什么你无法重现异常的原因。我已经安装了新插件 v3.8。名为“Forms Navigation”的示例模板现在生成与以前完全不同的代码。所以我认为你正在测试这个新代码,女巫在我的机器上工作得很好,但我已经在以前的示例代码之上构建了我的项目(见下文)。因此,如果我是正确的,请您尝试测试一下以前的代码,看看是否会遇到相同的异常。

package dk.cp3.anchorsafe;

import com.codename1.ui.Button;
import com.codename1.ui.CheckBox;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Command;
import com.codename1.ui.Dialog;
import com.codename1.ui.FontImage;
import com.codename1.ui.Image;
import com.codename1.ui.Label;
import com.codename1.ui.NavigationCommand;
import com.codename1.ui.RadioButton;
import com.codename1.ui.Slider;
import com.codename1.ui.TextField;
import com.codename1.ui.Toolbar;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BoxLayout;

/**
* This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
* of building native mobile applications using Java.
*/
public class AnchorSafely {

private Form current;
private Resources theme;

private Form home;

public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");

// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);

// Pro only feature, uncomment if you have a pro subscription
// Log.bindCrashProtection(true);
}

public void start() {
if (current != null) {
current.show();
return;
}

//create and build the home Form
home = new Form("Home");
home.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
home.addComponent(new Label("This is a Label"));
home.addComponent(new Button("This is a Button"));
TextField txt = new TextField();
txt.setHint("This is a TextField");
home.addComponent(txt);
home.addComponent(new CheckBox("This is a CheckBox"));
RadioButton rb1 = new RadioButton("This is a Radio Button 1");
rb1.setGroup("group");
home.addComponent(rb1);
RadioButton rb2 = new RadioButton("This is a Radio Button 2");
rb2.setGroup("group");
home.addComponent(rb2);
final Slider s = new Slider();
s.setText("50%");
s.setProgress(50);
s.setEditable(true);
s.setRenderPercentageOnTop(true);
home.addComponent(s);

Button b1 = new Button("Show a Dialog");
b1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
Dialog.show("Dialog Title", "Dialog Body", "Ok", "Cancel");
}
});
home.addComponent(b1);

//Create Form1 and Form2 and set a Back Command to navigate back to the home Form
Form form1 = new Form("Form1");
setBackCommand(form1);
Form form2 = new Form("Form2");
setBackCommand(form2);

//Add navigation commands to the home Form
NavigationCommand homeCommand = new NavigationCommand("Home");
homeCommand.setNextForm(home);
home.getToolbar().addCommandToSideMenu(homeCommand);

NavigationCommand cmd1 = new NavigationCommand("Form1");
cmd1.setNextForm(form1);
home.getToolbar().addCommandToSideMenu(cmd1);

NavigationCommand cmd2 = new NavigationCommand("Form2");
cmd2.setNextForm(form2);
home.getToolbar().addCommandToSideMenu(cmd2);

//Add Edit, Add and Delete Commands to the home Form context Menu
Image im = FontImage.createMaterial(FontImage.MATERIAL_MODE_EDIT, UIManager.getInstance().getComponentStyle("Command"));
Command edit = new Command("Edit", im) {

@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Editing");
}
};
home.getToolbar().addCommandToOverflowMenu(edit);

im = FontImage.createMaterial(FontImage.MATERIAL_LIBRARY_ADD, UIManager.getInstance().getComponentStyle("Command"));
Command add = new Command("Add", im) {

@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Adding");
}
};
home.getToolbar().addCommandToOverflowMenu(add);

im = FontImage.createMaterial(FontImage.MATERIAL_DELETE, UIManager.getInstance().getComponentStyle("Command"));
Command delete = new Command("Delete", im) {

@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Deleting");
}

};
home.getToolbar().addCommandToOverflowMenu(delete);

home.show();
}

protected void setBackCommand(Form f) {
Command back = new Command("") {

@Override
public void actionPerformed(ActionEvent evt) {
home.showBack();
}

};
Image img = FontImage.createMaterial(FontImage.MATERIAL_ARROW_BACK, UIManager.getInstance().getComponentStyle("TitleCommand"));
back.setIcon(img);
f.getToolbar().addCommandToLeftBar(back);
f.getToolbar().setTitleCentered(true);
f.setBackCommand(back);
}

public void stop() {
current = Display.getInstance().getCurrent();
}

public void destroy() {
}

}

最佳答案

当我看到视频时,我注意到您使用了商业主题,我认为这不是问题的原因,但事实确实如此。业务主题定义了已弃用的 commandBehavior 主题常量,您只需删除该常量即可解决此问题。

关于java - 更新后 codename1 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47141271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com