0
我在我的JPanel下面的方法:如何從一個JPanel值傳遞給一個JFrame在NetBeans
public void detectionTime(){
detectStartTime = System.currentTimeMillis();
long detectDuration = System.currentTimeMillis() - detectStartTime;
performance.lblDetectTime.setText(detectDuration + "ms");
}
我想在標籤即lblDetectTime在一個JFrame打印或輸出detectDuration變量。我已經創建了一個JFrame的實例作爲「性能」,並且我還創建了一個JPanel實例到JFrame中以訪問該方法。
我需要在JFrame中設置變量lblDetectTime到JPanel的detectDuration值。 – marlaw21 2012-07-15 16:10:06
你offcourse多數民衆贊成它是什麼...'IblDetectTime = MyPanel.detectionTime();' – 2012-07-15 16:17:14
它給了我一個不兼容的類型錯誤。 JLabel與String不兼容。我嘗試使用lblDetectTime.setText(detection.detectionTime());但它不起作用。 「檢測」是JPanel的一個實例 – marlaw21 2012-07-16 09:02:22