久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

TableColumn 中的 JavaFX 格式加倍

JavaFX format double in TableColumn(TableColumn 中的 JavaFX 格式加倍)
本文介紹了TableColumn 中的 JavaFX 格式加倍的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..
TableColumn<Product, Double> priceCol = new TableColumn<Product,Double>("Price");
priceCol.setCellValueFactory(new PropertyValueFactory<Product, Double>("price"));

如何將此列中的雙精度設置為具有 2 個小數位(因為它們是價格列)?默認情況下它們只顯示 1 個小數位.

How do I format the doubles in this column to have 2 decimal places(Because they are the column for price)?By default they only show 1 decimal place.

推薦答案

使用生成單元格的單元格工廠,該單元格使用貨幣格式化程序來格式化顯示的文本.這意味著價格將被格式化為當前語言環境中的貨幣(即使用當地貨幣符號和適當的小數位數規則等).

Use a cell factory that generates cells that use a currency formatter to format the text that is displayed. This means the price will be formatted as a currency in the current locale (i.e. using the local currency symbol and appropriate rules for number of decimal places, etc.).

NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
priceCol.setCellFactory(tc -> new TableCell<Product, Double>() {

    @Override
    protected void updateItem(Double price, boolean empty) {
        super.updateItem(price, empty);
        if (empty) {
            setText(null);
        } else {
            setText(currencyFormat.format(price));
        }
    }
});

注意這是除了你已經在使用的cellValueFactory.cellValueFactory 確定單元格中顯示的值;cellFactory 確定定義如何顯示它的單元格.

Note this is in addition to the cellValueFactory you are already using. The cellValueFactory determines the value that is displayed in a cell; the cellFactory determines the cell that defines how to display it.

這篇關于TableColumn 中的 JavaFX 格式加倍的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 欧美色性 | 国产精品亚洲一区二区三区在线 | 91视频网| 日韩欧美三区 | 天天干天天爱天天 | 精品国产免费一区二区三区演员表 | 亚洲视频欧美视频 | 中文在线一区二区 | 欧美日韩精品区 | 亚洲免费视频一区二区 | av中文字幕在线播放 | 亚洲成人一区二区 | 国产羞羞视频在线观看 | 超碰成人免费 | 涩涩视频网站在线观看 | 亚洲精品乱码8久久久久久日本 | 一区二区三区视频免费观看 | 精品毛片在线观看 | 麻豆91av | 91在线视频播放 | 成人免费在线电影 | 九九热在线免费视频 | 欧美一区二区三区四区视频 | 日韩一区中文字幕 | 免费h视频 | 久久久久久九九九九九九 | 免费一级欧美在线观看视频 | 成人一区精品 | 成人在线视 | 国产日韩一区二区三区 | 91精品一区二区三区久久久久久 | 久久久久久久久久久久久9999 | 成人欧美一区二区三区在线播放 | 国产成人福利在线观看 | 亚洲国产精品成人 | 国产精品3区 | 91精品国产日韩91久久久久久 | 午夜av在线 | 国产视频三级 | 亚洲欧美中文字幕在线观看 | 丁香五月网久久综合 |