Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: changing GUI

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default changing GUI

     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?


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: changing GUI

    Instead of making the JTextArea entirely inside a method, declare say "private JTextArea outputbox;" and then initialise it afterwards.
    Currently the scope of output box is local to incometaxcreator()
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: changing GUI

    well netbeans is giving me a green light but i don't see anything but that could be for plenty of reasons
    thanks

Similar Threads

  1. Changing how a Window is drawn.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 8th, 2011, 09:16 PM
  2. Boolean Value Not Changing
    By bosox960 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 21st, 2010, 02:11 PM
  3. [SOLVED] changing character repetition
    By vendetta in forum Algorithms & Recursion
    Replies: 2
    Last Post: February 16th, 2010, 06:16 PM
  4. Parameter's value is never changing
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 27th, 2009, 05:29 AM