进度条可以在主程序之外的类中使用吗?
import java.awt.*;import java.awt.event.*;import javax.swing.*;public class twoLoan extends JFrame { static JFrame progressFrame; static JProgressBar progressBar; static Container pane; double amountSaved = 0; int i = 0; public void runCalcs(Double MP, Double StepAmt, Double L1, Double L2, Double C1, Double C2, Double IM1, Double IM2, Double M1Start, Double M2Start) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } int iterations = (int) (MP - (M1Start * M2Start)); //Create all components progressFrame = new JFrame("Calculation Progress"); progressFrame.setSize(300, 100); pane = progressFrame.getContentPane(); pane.setLayout(null); progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); progressBar = new JProgressBar(0, iterations); //Add components to pane pane.add(progressBar); //Position controls (X, Y, width, height) progressBar.setBounds(10, 10, 280, 20); //Make frame visible progressFrame.setResizable(false); //No resize progressFrame.setVisible(true); double M1 = M1Start; double M2 = M2Start; // Set MinLoop as maximum to start // Loan 1 double N1 = (Math.log10(1 - IM1 * L1 / M1) * -1) / Math.log10(1 + IM1); double M1Sum = M1 * N1; // Loan 2 double N2 = (Math.log10(1 - IM2 * L2 / M2) * -1) / Math.log10(1 + IM2); double M2Sum = M2 * N2; double minLoop = M1Sum + M2Sum; double MTotal = 0;
叮当猫咪
相关分类