public void incometaxcreator() { JFrame incometaxframe = new JFrame("income tax generator"); JButton createincometax = new JButton("generate a list"); JTextArea outputbox = new JTextArea(); JTextArea inoutbox = new JTextArea(); incometaxframe.add(createincometax, BorderLayout.EAST); incometaxframe.add(outputbox, BorderLayout.WEST); incometaxframe.add(inoutbox, BorderLayout.CENTER); outputbox.setPreferredSize(new Dimension (500,200)); incometaxframe.setVisible(true); incometaxframe.setDefaultCloseOperation(incometaxframe.EXIT_ON_CLOSE); incometaxframe.setPreferredSize(new Dimension (1000,400)); incometaxframe.pack(); //create the listener that generates the list createincometax.addActionListener(new ActionListener( ) { public void actionPerformed(ActionEvent e) { //get the information from the textarea and store as a string String input= inoutbox.getText(); String output= input; //create the patterns and matchers Pattern student = Pattern.compile("cat"); Matcher studentmatcher = student.matcher(output); output =studentmatcher.replaceAll(Current.getStudentName()); outputbox.setText(output);
the problem is that it won't allow me to setText to the output box because this is in a different method how do i get around this?