Results 1 to 4 of 4
  1. #1
    Lyricid is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Exclamation display contents from System.out.println(); in a differnet class GUI

    i am trying to display the output of this

    int[] a = ArrayUtil.randomIntArray(r,t);
    ArrayUtil.print(a);
    SortingProcess sorter = new SortingProcess(a);
    sorter.sort();
    ArrayUtil.print(a);
    System.out.println("");

    in a jTextArea or jTextField

    any ideas??

    Many Thanks

    Sachin

  2. #2
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    Java Code:
    static String toLines(int [] a) {
        StringBuffer sb = new StringBuffer();
        for (int i : a)
            sb.add(i + "\n");
        return sb.toString();
    }
    ...{
         JTextArea jta = new JTextArea();
         int [] a;
         ...
         jta.setText(toLines(a));
    ...}

  3. #3
    Lyricid is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Default

    where would i add this in my code? i am currently using NetBeans to make my GUI and the system.out.println(); is in a different class....i want to link them but i dont know how

  4. #4
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

    Default

    Objects are "linked" by defining a method in one object and calling it from another.
    From the GUI methods are called by events on GUI objects.
    For instance, the GUI initialization code can call addActionListener for a button.
    The actionPerformed method in that listener
    will call the method to move the data to the JTextArea.

    See Learning Swing with the NetBeans IDE
    and especially Adding the Application Logic

Similar Threads

  1. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-18-2008, 11:06 PM
  2. System.out.println
    By Sniper-X in forum Advanced Java
    Replies: 10
    Last Post: 05-05-2008, 03:41 PM
  3. System.out.println
    By sunjavaboy in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2008, 01:30 AM
  4. Template for System.out.println
    By eva in forum Eclipse
    Replies: 3
    Last Post: 01-05-2008, 12:46 PM
  5. Help me with system.out.println
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •