好吧,所以我在我的学校有一个计算机科学项目。该项目是创建一个GUI,用于计算应该对个人收入征收多少税款。我遇到的问题是,每次我想运行程序时都需要3分钟才能使程序实际启动。包括我的老师在内的很多人都说这不正常。这是我的代码:
package me.findTax;
/*
* Notes:
* Fix the location of all the elements and create the math part of the program
*
* For some reason, takes eclipse a long time on home & school computers to run this program, not entirely sure why (2+ min)
*
* If something is not working, try looking a make sure that the change method is called after everytime that the getQuestion method is called
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class Main { //gives questions (source not included, keylistener included (currently not working), actionlistener included)
static JRadioButton b1;
static JRadioButton b2;
static JFrame frame;
static JPanel panel;
static JLabel L1;
static JLabel L2;
static JTextField tfield;
static ButtonGroup bg = new ButtonGroup();
static JButton B1;
static double tax;
static boolean married;
static ArrayList<String> poss_Questions = new ArrayList<String>();
private static int q;
// Only need 2 buttons because there is only one prompt (yes or no)
public static void change() {
if(q == 1) {
b1.setVisible(false);
b2.setVisible(false);
tfield.setVisible(true);
B1.setVisible(true);
} else if(q == 2) {
tfield.setVisible(false);
B1.setVisible(false);
L2.setText(Double.toString(tax)); //fix to make output more good
L2.setVisible(true);
L1.setLocation(10,20);
}
}
public static String getQuestion(){
String question = "";
if(q == 0){
question = poss_Questions.get(q);
} else if(q == 1){
question = poss_Questions.get(q);
} else if(q == 2){
doMath();
question = poss_Questions.get(q);
}
jeck猫
繁星淼淼
相关分类