优步克隆的麻烦

如何解决优步克隆的麻烦

嗨,大家好:我正在尝试使用Uber Clone代码,并且正在使用Netbeans。我有两个问题: 1).-在 countryPickerForm 清单4.12 中(清单编号是该书的清单“创建Uber克隆...”); Netbeans标记我一个错误,(““找不到符号变量CommonCode”),当然,在CommonCode对象中,我不知道要使用哪个库

´´´

public class CountryPickerForm extends Form{
    //@SuppressWarnings("LeakingThisInConstructor")
    public CountryPickerForm(Button sourceButton,Resources Flag){
        super(BoxLayout.y());
        **CommonCode.initBlackTitleForm(this,"Select a Country",val-> search(val));**
        Image blankIcon = Image.createImage(100,70,0);

´´´ 2).-第二个问题:列表(5.22) “在焦点更改时切换“ WhereTo?” UI”是正确的位置。。我将其放置在任何方法之外的MapForm类内部,但Neatbeans标记了一个错误:“ 预期。类型“ ”的非法开头 这是代码:

from.addFocusListener(new FocusListener(){
    public void focusGained(Component cmp){
        fromSelected.setIcon(square);
        if(layer.getComponentCount()> 1){
            Component c = layer.getComponentAt(1);
            c.setY(getDisplayHeight());
            layer.animateUnlayout(200,150,() ->{
            c.remove();
            revalidate();
        });
      }
    }
    
    public void focusLost(){
        fromSelected.setIcon(circle);
    }
});
to.addFocusListener(new FocusListener(){
    public void focusGained(Component cmp){
        fromSelected.setIcon(circle):
        toSelected.setIcon(square);
        showToNavigationBar(layer);
    }
    public void focusLost(Component cmp){
        toSelecte3dsetIcon(circle);
    }
});

谢谢你们!!!

解决方法

CommonCode在这本书的其中一项编辑中以某种方式丢失了。它是本书开头列出的可下载zip的一部分,应该在其中。这是该课程的完整清单:

package com.codename1.apps.uberclone.forms;

import com.codename1.apps.uberclone.server.UserService;
import com.codename1.components.MultiButton;
import com.codename1.io.Log;
import com.codename1.ui.Button;
import static com.codename1.ui.CN.*;
import com.codename1.ui.Command;
import com.codename1.ui.Container;
import com.codename1.ui.Display;
import com.codename1.ui.FontImage;
import com.codename1.ui.Form;
import com.codename1.ui.Graphics;
import com.codename1.ui.Image;
import com.codename1.ui.Label;
import com.codename1.ui.TextField;
import com.codename1.ui.Toolbar;
import com.codename1.ui.animations.CommonTransitions;
import com.codename1.ui.animations.Transition;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.layouts.LayeredLayout;
import com.codename1.ui.plaf.Style;
import com.codename1.util.LazyValue;
import com.codename1.util.SuccessCallback;
import java.io.IOException;

/**
 * Common code for construction and initialization of various classes e.g. the side menu logic etc.
 *
 * @author Shai Almog
 */
public class CommonCode {
    private static Image avatar;
    public static Image getAvatar(SuccessCallback<Image> avatarChanged) {
        if(avatar == null) {
            int size = convertToPixels(10);
            Image temp = Image.createImage(size,size,0xff000000);
            Graphics g = temp.getGraphics();
            g.setAntiAliased(true);
            g.setColor(0xffffff);
            g.fillArc(0,360);
            Object mask = temp.createMask();
            UserService.fetchAvatar(i -> {
                avatar = i.fill(size,size).applyMask(mask);
                avatarChanged.onSucess(avatar);
            });
            if(avatar != null) {
                return avatar;
            }
            Style s = new Style();
            s.setFgColor(0xc2c2c2);
            s.setBgTransparency(255);
            s.setBgColor(0xe9e9e9);
            FontImage x = FontImage.createMaterial(FontImage.MATERIAL_PERSON,s,size);
            avatar = x.fill(size,size);
            if(avatar instanceof FontImage) {
                avatar = ((FontImage)avatar).toImage();
            }
            avatar = avatar.applyMask(mask);
        }
        return avatar;
    }
    
    public static Image setAvatar(String imageFile) {
        int size = convertToPixels(10);
        Image temp = Image.createImage(size,0xff000000);
        Graphics g = temp.getGraphics();
        g.setAntiAliased(true);
        g.setColor(0xffffff);
        g.fillArc(0,360);
        Object mask = temp.createMask();
        
        try {
            Image img = Image.createImage(imageFile);
            avatar = img.fill(size,size).applyMask(mask);
        } catch(IOException err) {
            // this is unlikely as we just grabbed the image...
            Log.e(err);
        }
        return avatar;
    }
    
    public static MultiButton createEntry(char icon,String title) {
        MultiButton b = new MultiButton(title);
        b.setUIID("Container");
        b.setUIIDLine1("WhereToButtonLine1");
        b.setIconUIID("WhereToButtonIcon");
        FontImage.setMaterialIcon(b,icon);
        return b;
    }
    
    public static MultiButton createEntry(char icon,String title,String subtitle) {
        MultiButton b = new MultiButton(title);
        b.setTextLine2(subtitle);
        b.setUIID("Container");
        b.setUIIDLine1("WhereToButtonLineNoBorder");
        b.setUIIDLine2("WhereToButtonLine2");
        b.setIconUIID("WhereToButtonIcon");
        FontImage.setMaterialIcon(b,icon);
        return b;
    }
    
    
    public static Label createSeparator() {
        Label sep = new Label("","WhereSeparator");
        sep.setShowEvenIfBlank(true);
        return sep;
    }
    
    public static void constructSideMenu(Toolbar tb) {
        Button userAndAvatar = new Button("Shai Almog","AvatarBlock");
        userAndAvatar.setIcon(getAvatar(i -> userAndAvatar.setIcon(i)));
        userAndAvatar.setGap(convertToPixels(3));
        userAndAvatar.addActionListener(e -> new EditAccountForm().show());
        tb.addComponentToSideMenu(userAndAvatar);
        
        MultiButton uberForBusiness = new MultiButton("Do you Uber for business?");
        uberForBusiness.setTextLine2("Tap to create your business profile");
        uberForBusiness.setUIID("UberForBusinessBackground");
        uberForBusiness.setUIIDLine1("UberForBusinessLine1");
        uberForBusiness.setUIIDLine2("UberForBusinessLine2");
        tb.addComponentToSideMenu(uberForBusiness);
        
        tb.addCommandToSideMenu("Payment",null,e -> {});
        tb.addCommandToSideMenu("Your Trips",e -> {});
        tb.addCommandToSideMenu("Help",e -> {});
        tb.addCommandToSideMenu("Free Rides",e -> {});
        tb.addCommandToSideMenu("Settings",e -> new SettingsForm().show());
        
        Button legalButton = new Button("Legal","Legal");
        Container legal = BorderLayout.centerCenterEastWest(null,new Label("v4.178.1001","VersionNumber"),legalButton);
        legal.setLeadComponent(legalButton);
        legal.setUIID("SideNavigationPanel");
        tb.setComponentToSideMenuSouth(legal);
    } 
    
    
    /**
     * Initializes a form with a black background title animation style
     * @param f the form
     */
    public static void initBlackTitleForm(Form f,SuccessCallback<String> searchResults) {
        Form backTo = getCurrentForm();
        f.getContentPane().setScrollVisible(false);
        Button back = new Button("","TitleCommand");
        removeTransitionsTemporarily(backTo);
        back.addActionListener(e -> backTo.showBack());
        back.getAllStyles().setFgColor(0xffffff);
        FontImage.setMaterialIcon(back,FontImage.MATERIAL_ARROW_BACK);
                
        f.setBackCommand(new Command("") {
            @Override
            public void actionPerformed(ActionEvent evt) {
                backTo.showBack();
            }
        });

        Container searchBack = null;
        if(searchResults != null) {
            Button search = new Button("","TitleCommand");
            search.getAllStyles().setFgColor(0xffffff);
            FontImage.setMaterialIcon(search,FontImage.MATERIAL_SEARCH);
            search.addActionListener(e -> {
                
            });
            searchBack = BorderLayout.north(
                BorderLayout.centerEastWest(null,search,back));
        } else {
            searchBack = BorderLayout.north(
                BorderLayout.centerEastWest(null,back));
        }
        
        Label titleLabel = new Label(title,"WhiteOnBlackTitle");

        titleLabel.getAllStyles().setMarginTop(back.getPreferredH());
        titleLabel.getAllStyles().setMarginUnit(Style.UNIT_TYPE_PIXELS,Style.UNIT_TYPE_DIPS,Style.UNIT_TYPE_DIPS);
        
        f.getToolbar().setTitleComponent(LayeredLayout.encloseIn(searchBack,titleLabel));
        
        f.getAnimationManager().onTitleScrollAnimation(titleLabel.createStyleAnimation("WhiteOnBlackTitleLeftMargin",200));
        
        f.setTransitionInAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL,false,300));
        f.setTransitionOutAnimator(CommonTransitions.createUncover(CommonTransitions.SLIDE_VERTICAL,true,300));        
    }
    
    public static void removeTransitionsTemporarily(final Form f) {
        final Transition originalOut = f.getTransitionOutAnimator();
        final Transition originalIn = f.getTransitionInAnimator();
        f.setTransitionOutAnimator(CommonTransitions.createEmpty());
        f.setTransitionInAnimator(CommonTransitions.createEmpty());
        f.addShowListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                f.setTransitionOutAnimator(originalOut);
                f.setTransitionInAnimator(originalIn);
                f.removeShowListener(this);
            }
        });
    }
}

第二个列表显示在MapForm的{​​{1}}中。此代码稍后将进行一些其他的重构,如下所示:

showNavigationToolbar

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-