【问题标题】:Is there a way to get access on the values of a NumberAxis() in JavaFX 2.0 ?有没有办法访问 JavaFX 2.0 中 NumberAxis() 的值?
【发布时间】:2013-10-17 12:51:26
【问题描述】:

我想访问我的 X-AXIS 的每个特定值,它是 JavaFX 中的 NumberAxis。 假设我得到了new NumberAxis(0, 10, i),我想删除 Ticks 8 - 10;

我想过类似xAxis.getTickValues().get(8).remove(); xAxis.getTickValues().get(9).remove(); xAxis.getTickValues().get(10).remove();

访问我的 Tickvalues 的正确方法是什么?

【问题讨论】:

  • 不,不一样。我想我还不够清楚。 xD 要更改我们使用了 TickLabelFormatter 的值,这很好。但是我需要访问单个值以删除它们。我不确定这是否可能,因为没有方法。如果我们也可以使用 ticklabelformatter,我不知道该怎么做。

标签: java javafx-2 javafx


【解决方案1】:

您可以通过覆盖 DefaultFormatter 来格式化标签

    xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis) {
        @Override
        public String toString(Number number) {
            return (number.intValue() > 7) ? "" :  String.format("%2.0f", number);
        }
    });

【讨论】:

    猜你喜欢
    • 2013-10-24
    • 2014-09-03
    • 2020-04-28
    • 1970-01-01
    • 2010-10-17
    • 1970-01-01
    • 2014-12-22
    • 2021-04-04
    • 2018-08-18
    相关资源
    最近更新 更多