久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 久久久www成人免费无遮挡大片 | 在线观看视频h | 91精品国产91久久久久久丝袜 | 日韩在线三级 | 日韩一区二区三区在线 | 久久久久久国产 | 欧美影院久久 | 91久久精品日日躁夜夜躁欧美 | 国产伦一区二区三区视频 | 成人影院网站ww555久久精品 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 七七婷婷婷婷精品国产 | 草草草影院 | 中文字幕一区在线观看视频 | 成人亚洲综合 | 成人看片在线观看 | 狠狠干网 | 国产精品一区二区在线 | 在线视频一区二区三区 | 日韩综合一区 | 日日夜夜精品免费视频 | aaaaaaa片毛片免费观看 | 久久丝袜视频 | 国产精品视频区 | 国产一区二区三区 | 国产99久久 | 国产电影一区 | 91久久精品一区二区二区 | 国产精品伦理一区二区三区 | 欧美成年黄网站色视频 | 99免费在线视频 | 日韩二三区 | 在线视频成人 | 亚洲一区二区中文字幕 | 国产精品久久久久久久久久久久久久 | 日韩精品一区二区三区在线播放 | 男人的天堂在线视频 | 国内精品视频一区二区三区 | 一级欧美 | 九九久久精品 | 一级欧美 |