How to append text to a JTextArea?

Why won't my Java project run?

  • import java.awt.*; import java.awt.event.*; import java.text.*; import javax.swing.*; public class Project3 extends JFrame { private GUI GUIObject; private JButton numberAB, GUI; private JTextArea TextArea; private JTextField TextField; private JLabel numberinst; public Project3() { createUserInterface(); } private void createUserInterface() { Container contentPane = getContentPane(); contentPane.setLayout(null); numberinst = new JLabel(); numberinst.setText( "Type in the number you want to be extracted" ); numberinst.setBounds( 150, 0, 500, 100); numberinst.setFont( new Font( "", Font.PLAIN, 20)); numberinst.setVisible(false); contentPane.add( numberinst ); TextField = new JTextField(); TextField.setText( "" ); TextField.setBounds( 300, 100, 100, 50); TextField.setVisible(false); TextField.setFont( new Font( "", Font.PLAIN, 20)); contentPane.add( TextField ); TextArea = new JTextArea(); TextArea.setText( "" ); TextArea.setBounds( 50, 325, 600, 125); TextArea.setVisible(false); TextArea.setEditable(false); contentPane.add( TextArea ); numberAB = new JButton(); numberAB.setText( "Convert" ); numberAB.setBounds( 300, 200, 100, 40 ); numberAB.setVisible(false); contentPane.add( numberAB ); numberAB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { numberConvertActionPerformed( event ); } } ); } private void numberJTextFieldKeyPressed( KeyEvent event ) { TextArea.setText(""); } private void numberConvertActionPerformed( ActionEvent event ) { int number = Integer.parseInt(TextField.getText()); if(number > 0 && number < 1000000) { int first = number / 100000; int second = number / 10000 - first * 10; int third = number / 1000 - first * 100 - second * 10; int fourth = number / 100 - first * 1000 - second * 100 - third * 10; int fifth = number / 10 - first * 10000 - second * 1000 - third * 100 - fourth * 10; int sixth = number - first * 100000 - second * 10000 - third * 1000 - fourth * 100 - fifth * 10; if( number > 99999) { switch(first) { case 1: TextArea.append("one hundred "); break; case 2: TextArea.append("two hundred "); break; case 3: TextArea.append("three hundred "); break; case 4: TextArea.append("four hundred "); break; case 5: TextArea.append("five hundred "); break; case 6: TextArea.append("six hundred "); break; case 7: TextArea.append("seven hundred "); break; case 8: TextArea.append("eight hundred "); break; case 9: TextArea.append("nine hundred "); break; } if(second< 20 && second>9) { switch(second) { case 10: TextArea.append("ten thousand "); break; case 11: TextArea.append("eleven thousand "); break; case 12: TextArea.append("twelve thousand "); break; case 13: TextArea.append("thirteen thousand "); break; case 14: TextArea.append("fourteen thousand "); break; case 15: TextArea.append("fifteen thousand "); break; case 16: TextArea.append("sixteen thousand "); break; case 17: TextArea.append("seventeen thousand "); break; case 18: TextArea.append("eighteen thousand "); break; case 19: TextArea.append("nineteen thousand "); break; } } else if(true) { switch(second) { case 0: TextArea.append("thousand"); break; case 2: TextArea.append("twenty "); break; case 3: TextArea.append("thirty "); break; case 4: TextArea.append("fourty "); break; case 5: TextArea.append("fifty "); break; case 6: TextArea.append("sixty "); break; case 7: TextArea.append("seventy "); break; case 8: TextArea.append("eighty "); break; case 9: TextArea.append("ninety "); break; } } switch(third) { case 0: TextArea.append(""); break; case 1: TextArea.append("one thousand "); break; case 2: TextArea.append("two thousand "); break; case 3: TextArea.append("three thousand "); break; case 4: TextArea.append("four thousand "); break; case 5: TextArea.append("five thousand "); break; case 6: TextArea.append("six thousand "); break; case 7: TextArea.append("seven thousand "); break; case 8: TextArea.append("eight thousand "); break; case 9: TextArea.append("nine thousand"); break; } switch(fourth) { case 1: TextArea.append("one hundred "); break; case 2: TextArea.append("two hundred "); break; case 3: TextArea.append("three hundred "); break; case 4: TextArea.append("four hundred "); break; case 5: TextArea.append("five hundred "); break; case 6: TextArea.append("six hundr

  • Answer:

    Not all the devs have time to check ur code in this way. From now on in ur career as a developer, post the errors, just the line of the error, aditional details,etc. Regards...

Chuck Juday at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.