暑假) 学习总结

一直都在试图解决空指针异常

在vbox里添加一个好友控件,用anchorpane,anchorpane里放ImageView(放头像)和label(id、账号)

AnchorPane ap = new AnchorPane();
            ap.setPrefHeight(60);
            ImageView iv = new ImageView(new Image("Images/strawberr.png"));
            iv.setFitWidth(40);
            iv.setFitHeight(40);
            Label l1 = new Label("名字" + i);
            l1.setFont(new javafx.scene.text.Font(15));
            l1.setMaxWidth(160);
            Label l2 = new Label("编辑个性签名");
            l2.setFont(new javafx.scene.text.Font(12));
            l2.setMaxWidth(160);
            l2.setTextFill(Paint.valueOf("#aba6a6"));

            ap.getChildren().addAll(iv,l1,l2);

            AnchorPane.setLeftAnchor(iv, 34.0);
            AnchorPane.setTopAnchor(iv, 10.0);

            AnchorPane.setLeftAnchor(l1, 91.0);
            AnchorPane.setTopAnchor(l1, 10.0);

            AnchorPane.setLeftAnchor(l2, 91.0);
            AnchorPane.setTopAnchor(l2, 36.0);

            System.out.println(iv);
            friendVBox.getChildren().add(ap);

短短的几行代码,报的错比代码还多,人都麻了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值