그래서 저는 java와 gui에서 새로 생겼습니다. 우리는이 프로젝트를 통해 GUI와 함께 특정 작업을 수행 할 자바 프로그램을 만들었습니다. 나는이 오류가 발생했습니다 "오류가 자바에서 성명을"수있는 시체를 좀 도와 줄래? 그리고 텍스트 필드의 공간을 줄여보다 우아하게 만들 수 있습니까? 내 코드는 다음과 같습니다.오류 메시지가 자바에 없습니다
public class PHYSL_PROJ implements ActionListener
{
private JFrame f;
private JPanel p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13;
private JLabel MASS_OF_CALORIMETER, MASS_OF_STIRRER, SPECIFIC_HEAT_OF_CALORIMETER, SPECIFIC_HEAT_OF_STIRRER, MASS_OF_CALORIMETER_AND_WATER, MASS_OF_WATER, INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER, EQUILIBRIUM_TEMP, MASS_OF_WATER_CALORIMETER_AND_STEAM, MASS_OF_STEAM, COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER, ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER, PERCENT_ERROR;
private JButton COMPUTE, RESET;
private JTextField MASS_OF_CALORIMETER_t, MASS_OF_STIRRER_t, SPECIFIC_HEAT_OF_CALORIMETER_t, SPECIFIC_HEAT_OF_STIRRER_t, MASS_OF_CALORIMETER_AND_WATER_t, MASS_OF_WATER_t, INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t, EQUILIBRIUM_TEMP_t, MASS_OF_WATER_CALORIMETER_AND_STEAM_t, MASS_OF_STEAM_t, COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t, ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t, PERCENT_ERROR_t;
public PHYSL_PROJ()
{
f = new JFrame("Heat of Fusion Calculator");
p0 = new JPanel();
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
p6 = new JPanel();
p7 = new JPanel();
p8 = new JPanel();
p9 = new JPanel();
p10 = new JPanel();
p11 = new JPanel();
p12 = new JPanel();
p13 = new JPanel();
MASS_OF_CALORIMETER = new JLabel("Mass of calorimeter");
MASS_OF_STIRRER = new JLabel("Mass of stirrer");
SPECIFIC_HEAT_OF_CALORIMETER = new JLabel("Specific Heat of Calorimeter");
SPECIFIC_HEAT_OF_STIRRER = new JLabel("Specific Heat of Stirrer");
MASS_OF_CALORIMETER_AND_WATER = new JLabel("Mass of calorimeter and water");
MASS_OF_WATER = new JLabel("Mass of water (Mw)");
INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER = new JLabel("Initial temperature of water, calorimeter and stirrer (T0)");
EQUILIBRIUM_TEMP = new JLabel("Equilibrium temperature (Tf)");
MASS_OF_WATER_CALORIMETER_AND_STEAM = new JLabel("Mass of water, calorimeter and condensed steam");
MASS_OF_STEAM = new JLabel("Mass of steam (Mx)");
COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER = new JLabel("Computed value of heat of vaporization of water (Lv)");
ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER = new JLabel("Accepted value of heat of vaporization of water (Lv)");
PERCENT_ERROR =new JLabel("Percent error");
MASS_OF_CALORIMETER_t = new JTextField("0.0", 5);
MASS_OF_STIRRER_t = new JTextField("0.0", 5);
SPECIFIC_HEAT_OF_CALORIMETER_t = new JTextField("0.430", 5);
SPECIFIC_HEAT_OF_CALORIMETER_t.setEditable(false);
SPECIFIC_HEAT_OF_STIRRER_t = new JTextField("0.118", 5);
SPECIFIC_HEAT_OF_STIRRER_t.setEditable(false);
MASS_OF_CALORIMETER_AND_WATER_t = new JTextField("0.0", 5);
MASS_OF_WATER_t = new JTextField("0.0", 5);
MASS_OF_WATER_t.setEditable(false);
INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t = new JTextField("0.0", 5);
EQUILIBRIUM_TEMP_t = new JTextField("0.0", 5);
MASS_OF_WATER_CALORIMETER_AND_STEAM_t = new JTextField("0.0", 5);
MASS_OF_STEAM_t = new JTextField("0.0", 5);
MASS_OF_STEAM_t.setEditable(false);
COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t = new JTextField("0.0", 5);
COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setEditable(false);
ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t = new JTextField("540", 5);
ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setEditable(false);
PERCENT_ERROR_t = new JTextField("0.0%", 5);
PERCENT_ERROR_t.setEditable(false);
COMPUTE = new JButton("Compute");
RESET = new JButton("Reset");
}
public void launchFrame()
{
p0.setLayout(new GridLayout(1,2));
p1.setLayout(new GridLayout(1,2));
p2.setLayout(new GridLayout(1,2));
p3.setLayout(new GridLayout(1,2));
p4.setLayout(new GridLayout(1,2));
p5.setLayout(new GridLayout(1,2));
p6.setLayout(new GridLayout(1,2));
p7.setLayout(new GridLayout(1,2));
p8.setLayout(new GridLayout(1,2));
p9.setLayout(new GridLayout(1,2));
p10.setLayout(new GridLayout(1,2));
p11.setLayout(new GridLayout(1,2));
p12.setLayout(new GridLayout(1,2));
p13.setLayout(new GridLayout(1,2));
p0.add(MASS_OF_CALORIMETER);
p0.add(MASS_OF_CALORIMETER_t);
p1.add(MASS_OF_STIRRER);
p1.add(MASS_OF_STIRRER_t);
p2.add(SPECIFIC_HEAT_OF_CALORIMETER);
p2.add(SPECIFIC_HEAT_OF_CALORIMETER_t);
p3.add(SPECIFIC_HEAT_OF_STIRRER);
p3.add(SPECIFIC_HEAT_OF_STIRRER_t);
p4.add(MASS_OF_CALORIMETER_AND_WATER);
p4.add(MASS_OF_CALORIMETER_AND_WATER_t);
p5.add(MASS_OF_WATER);
p5.add(MASS_OF_WATER_t);
p6.add(INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER);
p6.add(INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t);
p7.add(EQUILIBRIUM_TEMP);
p7.add(EQUILIBRIUM_TEMP_t);
p8.add(MASS_OF_WATER_CALORIMETER_AND_STEAM);
p8.add(MASS_OF_WATER_CALORIMETER_AND_STEAM_t);
p9.add(MASS_OF_STEAM);
p9.add(MASS_OF_STEAM_t);
p10.add(COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER);
p10.add(COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t);
p11.add(ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER);
p11.add(ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t);
p12.add(PERCENT_ERROR);
p12.add(PERCENT_ERROR_t);
p13.add(COMPUTE);
p13.add(RESET);
f.setLayout(new GridLayout(14,2));
f.add(p0);
f.add(p1);
f.add(p2);
f.add(p3);
f.add(p4);
f.add(p5);
f.add(p6);
f.add(p7);
f.add(p8);
f.add(p9);
f.add(p10);
f.add(p11);
f.add(p12);
f.add(p13);
f.pack();
f.setVisible(true);
COMPUTE.addActionListener(this);
RESET.addActionListener(this);
f.addWindowListener(new MyCloseEventHandler());
}
public void actionPerformed(ActionEvent ae)
{
Object source = ae.getSource();
double mass_of_calorimeter, mass_of_stirrer, specific_heat_of_calorimeter = 0.430, specific_heat_of_stirrer = 0.118, mass_of_calorimeter_and_water, mass_of_water = 0.0, initial_temp_of_water_calorimeter_and_stirrer, equilibrium_temp, mass_of_water_calorimeter_and_steam, mass_of_steam = 0.0, computed_value_of_heat_of_vaporization_of_water = 0.0, accepted_value_of_heat_of_vaporization_of_water = 540, heat_of_vaporization_percent_error = 0.0;
if (MASS_OF_CALORIMETER_t.getText() != null && MASS_OF_STIRRER_t.getText() != null && SPECIFIC_HEAT_OF_CALORIMETER_t.getText() != null && SPECIFIC_HEAT_OF_STIRRER_t.getText() != null && MASS_OF_CALORIMETER_AND_WATER_t.getText() != null && MASS_OF_WATER_t.getText() != null && INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t.getText() != null && EQUILIBRIUM_TEMP_t.getText() != null && MASS_OF_WATER_CALORIMETER_AND_STEAM_t.getText() != null && MASS_OF_STEAM_t.getText() != null && COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.getText() != null && ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.getText() != null && PERCENT_ERROR_t.getText() != null)
{
mass_of_calorimeter = Double.parseDouble(MASS_OF_CALORIMETER_t.getText());
mass_of_stirrer = Double.parseDouble(MASS_OF_STIRRER_t.getText());
mass_of_calorimeter_and_water = Double.parseDouble(MASS_OF_CALORIMETER_AND_WATER_t.getText());
initial_temp_of_water_calorimeter_and_stirrer = Double.parseDouble(INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t.getText());
equilibrium_temp = Double.parseDouble(EQUILIBRIUM_TEMP_t.getText());
mass_of_water_calorimeter_and_steam = Double.parseDouble(MASS_OF_WATER_CALORIMETER_AND_STEAM_t.getText());
if (source == COMPUTE)
{
mass_of_water = mass_of_calorimeter_and_water - mass_of_calorimeter;
mass_of_steam = mass_of_water_calorimeter_and_steam - (mass_of_water - mass_of_calorimeter);
computed_value_of_heat_of_vaporization_of_water = (((mass_of_water(1) + mass_of_calorimeter(0.430) + mass_of_stirrer(0.118))(equilibrium_temp - initial_temp_of_water_calorimeter_and_stirrer)) + ((mass_of_steam(1)(equilibrium_temp - 100))))/mass_of_steam;
heat_of_vaporization_percent_error = ((accepted_value_of_heat_of_vaporization_of_water - computed_value_of_heat_of_vaporization_of_water)/accepted_value_of_heat_of_vaporization_of_water)*100;
}
else if (source == RESET)
{
MASS_OF_CALORIMETER_t.setText ("0.0");
MASS_OF_STIRRER_t.setText ("0.0");
SPECIFIC_HEAT_OF_CALORIMETER_t.setText ("0.430");
SPECIFIC_HEAT_OF_STIRRER_t.setText ("0.118");
MASS_OF_CALORIMETER_AND_WATER_t.setText ("0.0");
MASS_OF_WATER_t.setText ("0.0");
INITIAL_TEMP_OF_WATER_CALORIMETER_AND_STIRRER_t.setText ("0.0");
EQUILIBRIUM_TEMP_t.setText ("0.0");
MASS_OF_WATER_CALORIMETER_AND_STEAM_t.setText ("0.0");
MASS_OF_STEAM_t.setText ("0.0");
COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setText ("0.0");
ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setText ("540");
PERCENT_ERROR_t.setText ("0.0");
}
else {}
MASS_OF_WATER_t.setText("" + mass_of_water);
MASS_OF_STEAM_t.setText("" + mass_of_steam);
COMPUTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setText("" + computed_value_of_heat_of_vaporization_of_water);
ACCEPTED_VALUE_OF_HEAT_OF_VAPORIZATION_OF_WATER_t.setText("" + accepted_value_of_heat_of_vaporization_of_water);
PERCENT_ERROR_t.setText("" + heat_of_vaporization_percent_error);
}
}
private class MyCloseEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent ae)
{
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public static void main(String args[])
{
PHYSL_PROJ sc = new PHYSL_PROJ();
sc.launchFrame();
}
}
이 오류를 나타내는 줄은 무엇입니까? 그게 분명 도움이 될거야, 그렇지 않니? – Kon
모든 JPanels가 필요하지는 않습니다. 박쥐 바로 잘못된 디자인. – duffymo
이 부분은 다음과 같은 냄새가 난다 : else {}' –