为什么在将事件添加到每个饼图切片后,JavaFX PieChart标签不显示?(Why does JavaFX PieChart label not show after after adding Events to each pie slice? (Java 8))
我正在学习本教程(底部的部分称为“处理饼图的鼠标事件”):
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pie-chart.htm
我的代码如下:
@FXML public void initialize() { pieChart.setTitle("Breakdown of Customers by City"); pieChart.setLegendSide(Side.LEFT); final Task<ObservableList<PieChart.Data>> task = new NumClientsAtLocationTask(new CustomerAccountDaoSelect()); new Thread(task).start(); task.setOnSucceeded(ae -> { pieChart.setData(task.getValue()); final Label caption = new Label(""); caption.setTextFill(Color.DARKORANGE); caption.setStyle("-fx-font: 24 arial;"); for (final PieChart.Data data : pieChart.getData()) { data.getNode().addEventHandler(MouseEvent.MOUSE_PRESSED, ae2 -> { caption.setTranslateX(ae2.getSceneX()); caption.setTranslateY(ae2.getSceneY()); caption.setText(String.valueOf(data.getPieValue())); }); } }); } class NumClientsAtLocationTask extends Task<ObservableList<PieChart.Data>> { private DaoSelect<CustomerAccount> customerAccountDaoSelect; NumClientsAtLocationTask(DaoSelect<CustomerAccount> customerAccountDaoSelect) { this.customerAccountDaoSelect = customerAccountDaoSelect; } @Override protected ObservableList<PieChart.Data> call() throws Exception { List<CustomerAccount> customerAccounts = customerAccountDaoSelect.select(RunListeners.FALSE); Map<String, List<CustomerAccount>> customerMap = customerAccounts .stream() .collect(Collectors.groupingBy(CustomerAccount::getCity)); int london = customerMap.get("London").size(); int phoenix = customerMap.get("Phoenix").size(); int newYork = customerMap.get("New York").size(); ObservableList<PieChart.Data> results = FXCollections.observableArrayList( new PieChart.Data("London", london), new PieChart.Data("Phoenix", phoenix), new PieChart.Data("New York", newYork)); updateValue(results); return results; } }
图表以默认形式显示正常,但是当我在切片上单击鼠标时,标签不会出现。 如果我将标签打印到控制台,它会显示正确的值,它不会像在教程中那样显示在屏幕上。 有任何想法吗?
I'm following this tutorial (the section at the bottom called "Processing Mouse Events for a Pie Chart"):
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pie-chart.htm
And my code is as follows:
@FXML public void initialize() { pieChart.setTitle("Breakdown of Customers by City"); pieChart.setLegendSide(Side.LEFT); final Task<ObservableList<PieChart.Data>> task = new NumClientsAtLocationTask(new CustomerAccountDaoSelect()); new Thread(task).start(); task.setOnSucceeded(ae -> { pieChart.setData(task.getValue()); final Label caption = new Label(""); caption.setTextFill(Color.DARKORANGE); caption.setStyle("-fx-font: 24 arial;"); for (final PieChart.Data data : pieChart.getData()) { data.getNode().addEventHandler(MouseEvent.MOUSE_PRESSED, ae2 -> { caption.setTranslateX(ae2.getSceneX()); caption.setTranslateY(ae2.getSceneY()); caption.setText(String.valueOf(data.getPieValue())); }); } }); } class NumClientsAtLocationTask extends Task<ObservableList<PieChart.Data>> { private DaoSelect<CustomerAccount> customerAccountDaoSelect; NumClientsAtLocationTask(DaoSelect<CustomerAccount> customerAccountDaoSelect) { this.customerAccountDaoSelect = customerAccountDaoSelect; } @Override protected ObservableList<PieChart.Data> call() throws Exception { List<CustomerAccount> customerAccounts = customerAccountDaoSelect.select(RunListeners.FALSE); Map<String, List<CustomerAccount>> customerMap = customerAccounts .stream() .collect(Collectors.groupingBy(CustomerAccount::getCity)); int london = customerMap.get("London").size(); int phoenix = customerMap.get("Phoenix").size(); int newYork = customerMap.get("New York").size(); ObservableList<PieChart.Data> results = FXCollections.observableArrayList( new PieChart.Data("London", london), new PieChart.Data("Phoenix", phoenix), new PieChart.Data("New York", newYork)); updateValue(results); return results; } }
The chart shows fine in its default form, but when I click the mouse on a slice, the label doesn't appear. If I print the label to console, it shows the correct value, it's just not showing up on screen like in the tutorial. Any ideas?
原文:https://stackoverflow.com/questions/43969193
最满意答案
现在有一个可以在Account Kit Web电子邮件流中使用的重定向URL。 此URL也需要添加到developer.facebook.com上的Account Kit应用程序设置中。 API参考: https : //developers.facebook.com/docs/accountkit/webjs/reference
There is now a redirect URL that can be used in Account Kit web email flow. This URL needs to also be added to the Account Kit app settings on developer.facebook.com. API Reference: https://developers.facebook.com/docs/accountkit/webjs/reference
相关问答
更多-
嘿,我只是想和你核对一下,看看你是否还有这个问题? 事情现在应该可以在AccountKit方面正常工作,但如果您仍然遇到问题,请提交一个请求,其中包含您的应用ID: https : //developers.facebook.com/bugs/ Hey I just wanted to check with you and see if you're still having this issue? Things should be working fine from the AccountKit side ...
-
Facebook登录和帐户套件是单独的产品。 当有人使用帐户套件登录时,您作为开发人员获得的只是他们的电话号码或电子邮件。 如果您想要Facebook个人资料图片,名称等,您应该使用Facebook登录。 Facebook Login and Account Kit are separate products. When somebody logs in with Account Kit all that you get as a developer is their phone number or ema ...
-
在帐户套件流程结束时,您(开发人员)获取已验证的电话号码。 如果您传递的是初始电话号码,或者您使用的是Android系统并且已有READ_PHONE_STATE并且SIM卡电话号码已填充,则通过此流程的人员可能会对其进行编辑,因为他们可能想使用其他电话号码。 但是,在经验结束时返回给您(开发人员)的是经过确认的。 在此处查看文档末尾的电话号码提取: https : //developers.facebook.com/docs/accountkit/webjs At the end of the Accoun ...
-
语音通话和Facebook通知仅作为短信未到达时接收代码的辅助方法。 您可以通过在AccountKitConfigurationBuilder中设置setVoiceCallbackNotificationsEnabled和setFacebookNotificationsEnabled来打开/关闭这些功能。 语音呼叫不能用作代码验证的主要来源 Voice calls and Facebook notifications are only available as secondary methods of re ...
-
AccountKit目前没有这样的功能。 虽然您可以自己实现此方法的一种方法是为每个应用程序登录存储电话号码(或电子邮件,如果您使用该流程),并在您自己的数据中交叉引用它们。 There's currently no such feature for AccountKit. Though one way that you can implement this yourself is by storing the phone number (or email, if you use that flow) fo ...
-
现在有一个可以在Account Kit Web电子邮件流中使用的重定向URL。 此URL也需要添加到developer.facebook.com上的Account Kit应用程序设置中。 API参考: https : //developers.facebook.com/docs/accountkit/webjs/reference There is now a redirect URL that can be used in Account Kit web email flow. This URL need ...
-
不,你不应该。 Facebook ID和帐户套件ID是两个不同的东西。 用户的Facebook ID是一种常量,因为仅针对该特定用户为您的app生成帐户工具包ID。 您不应将这些ID组合在一起以存储user_id。 主要原因是这种方式限制每个用户始终只使用一种方法登录。 如果用户有时想使用他的Facebook登录,有时使用帐户套件,该怎么办? 解释您可能遇到的问题 - 想象一下,用户首先使用Facebook登录进入您的应用程序,因此您将用户的user_id设置为他/她的Facebook ID。 然后,同一用 ...
-
“打开应用程序”按钮有一个链接,此时无效,因为您的应用程序无法处理它。 它看起来像这样: ak21************7://authorize/ 复制该链接并在AndroidManifest.xml中使用它来定义intent-filter,因此当您单击它时,您的应用程序将启动。 喜欢这个:
Facebook帐户套件设置(Facebook Account Kit Setup)[2022-03-19]
如果您转到应用程序面板中的应用程序,则可以找到您的Facebook应用程序ID和帐户工具包访问令牌。 应用仪表板位于: https : //developers.facebook.com/apps/INSERT_YOUR_APP_ID/dashboard/ 要添加帐户工具包,请单击左侧的“+添加产品”。 设置中的账户套件页面将显示您的客户令牌,主仪表板页面将显示Facebook应用程序ID。 You can find your Facebook App ID and Account Kit access t ...Facebook帐户套件(Facebook account kit)[2023-01-02]
您可以通过具有受支持的国家/地区代码的帐户工具包验证和电话号码( https://developers.facebook.com/docs/accountkit/countrycodes )。 他们不必在Facebook帐户上。 使用Account Kit创建的帐户绝不会链接到Facebook帐户。 即时验证(在上面的评论中引用)用于验证给定设备上的电话号码,但不创建该帐户套件帐户与Facebook帐户之间的链接。 You can verify and phone number through Accoun ...相关文章
更多- JFreeChart创建饼图PieChart
- HTML5服务器事件发送(Server-Sent Events)【HTML5教程 - 第十三篇】
- JavaFx Main中怎么绑定Java类中的一个static变量呢?
- ios label 竖排设置
- 如何实现:一个Tab中的List点击某个Item后想把该项添加到另一个tab中的ListView中?
- java连接数据库问题 不显示内容
- solr搜索提示,将词添加到词库中
- mongodb添加集合文档操作-使用shell和java操作mongodb文档
- 不显示删除回复显示所有回复显示星级回复显示得分回复 请问java Object的hashcode()方法是怎么实现的啊,内部的算法是什么啊
- MyBatis Java API详解
最新问答
更多- 使用通配符获取更多servlet请求变量[重复](Get more servlet request variables using wildcards [duplicate])
- 返回相同的集合类型,参数化不同(Returning same collection type, differently parameterised)
- C ++朋友函数模板重载和SFINAE在clang ++,g ++,vc ++中的不同行为(C ++ 14模式)(C++ friend function template overloading and SFINAE different behaviors in clang++, g++, vc++ (C++14 mode))
- 与paure IoT-Hub的Python paho-MQTT连接(Python paho-MQTT connection with azure IoT-Hub)
- 编译器警告“来自不同的Objective-C类型的赋值”(Compiler warning “assignment from distinct objective-c type”)
- C ++编译错误(在此函数中未初始化)[重复](C++ Compile Error (uninitialized in this function) [duplicate])
- unsigned-signed下溢机制(unsigned-signed underflow mechanism)
- 快速行查询的数据结构?(Data structure for fast line queries?)
- 饥荒有手机安卓版的吗
- Jquery可拖动碰撞检测错误(Jquery draggable collision detection bug)
- sql调优是怎样来实现的?
- 无法使占位符输入文本消失(Unable to make the placeholder input text disappear)
- jQuery改变了两个div的CSS属性(JQuery change CSS property of two div's)
- JDK中包含的库版本(Versions of libraries included in the JDK)
- 请问下载的是出现ASP是什么意思
- Firebase MLkit用于数字液晶显示器的文本识别(Firebase MLkit Text recognition for digital lcd displays)
- 我可以在任何平台上运行C和C ++吗?(Can I run C and C++ on any platform?)
- 让小组在C#的特定位置(get panel at specific positions in C#)
- Nagios为通知设置了更高的间隔(Nagios set higher interval for notifications)
- 无法向SMTP主机发送电子邮件(unable to send an email to SMTP host)
- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何在.NET代码中验证全球邮政编码(How can I validate worldwide postal codes in my .NET code)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- Clojure:减少大型懒惰收集会占用内存(Clojure: Reducing large lazy collection eats up memory)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- 显示作为字符串的SVG(Showing an SVG that I have as a string)
- 从jansson库里创建json请求的自由内存的正确方式是什么?(what is the proper way of free memory in creating json request from jansson libary?)
- jQuery插件无法正常工作 - 它是附加的(jQuery plugin not working - it's appended)
- 使用stat_summary自动调整ylim(Automatically adjusting ylim with stat_summary)