Making a small application for a school project, I'm basically done except for this one thing. In my first panel people can fill in hours for each day. Those numbers from the textfield need to get added up and the result shown in a textfield in a second panel.
Here the input gets added up in the action listener:
public class knopHandler implements ActionListener
{
public void actionPerformed ( ActionEvent e )
{
JFrame frame2 = new JFrame ( "Total Hours" );
frame2.setSize ( 600, 500 );
JPanel uitvoerpanel = new uitvoerpanel();
frame2.setContentPane( uitvoerpanel );
frame2.setVisible( true );
String invoerstring1 = maandaginvoer.getText();
int getal1 = Integer.parseInt( invoerstring1 );
String invoerstring2 = dinsdaginvoer.getText();
int getal2 = Integer.parseInt( invoerstring2 );
String invoerstring3 = woensdaginvoer.getText();
int getal3 = Integer.parseInt( invoerstring3 );
String invoerstring4 = donderdaginvoer.getText();
int getal4 = Integer.parseInt( invoerstring4 );
String invoerstring5 = vrijdaginvoer.getText();
int getal5 = Integer.parseInt( invoerstring5 );
String invoerstring6 = zaterdaginvoer.getText();
int getal6 = Integer.parseInt( invoerstring6 );
String invoerstring7 = zondaginvoer.getText();
int getal7 = Integer.parseInt( invoerstring7 );
int resultaat = getal1 + getal2 + getal3 + getal4 + getal5 + getal6
+ getal7;
Now the int resultaat
needs to show up in totaalurenvak
in the new panel
totaalurenvak = new JTextField ( 20 );
totaalurenvak.setHorizontalAlignment ( JTextField.LEFT );
totaalurenvak.setEditable ( false );
totaalurenvak.setText(Integer.toString( resultaat) );
Now this is the latest line of code I tried, I have also tried totaalurenvak.setText("" + resultaat);
or totaalurenvak.setText(Integer.parseInt ( resultaat) );
Might be worth noting that the input from 2 other textfields do show up in the second panel, only this does not so what is going wrong here exactly? whatever line of code I try the compiler tells me "cannot find symbol".