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 4 of 4

Thread: New Line in swing

  1. #1
    Member
    Join Date
    Sep 2012
    Posts
    98
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default New Line in swing

    How do i add a new line in Swing? Im using netbeans, here is my source code:
    This is what it outputs:
    I want the output to be organized, like this:
    1 Computer - 706
    100 Computers = 70600
    200 Computers - 141200
    etc , How do i change this?
    1 Computer	706 100 Computer	70600 200 Computer	141200 300 Computer	211800 400 Computer	282400 500 Computer	353000 600 Computer	423600 700 Computer	494200 800 Computer	564800 900 Computer	635400 1000 Computer	706000
    To clarify, it is showing the output straight across the screen.
     private void CostWOutShippingActionPerformed(java.awt.event.ActionEvent evt) {
            Output.setText(Output.getText() + "1 Computer" + "\t" + 706  + "\n" ); 
            Output.setText(Output.getText() + "100 Computers" + "\t" + 70600  + "\n" );
            Output.setText(Output.getText() + "200 Computers" + "\t" + 141200  + "\n" );
            Output.setText(Output.getText() + "300 Computer" + "\t" + 211800  + "\n" );
            Output.setText(Output.getText() + "400 Computer" + "\t" + 282400  + "\n" );
            Output.setText(Output.getText() + "500 Computer" + "\t" + 353000  + "\n" );
            Output.setText(Output.getText() + "600 Computer" + "\t" + 423600  + "\n" );
            Output.setText(Output.getText() + "700 Computer" + "\t" + 494200  + "\n" );
            Output.setText(Output.getText() + "800 Computer" + "\t" + 564800  + "\n" );
            Output.setText(Output.getText() + "900 Computer" + "\t" + 635400  + "\n" );
            Output.setText(Output.getText() + "1000 Computer" + "\t" + 706000  + "\n" );
        }


  2. #2
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: New Line in swing

    Try
     private void CostWOutShippingActionPerformed(java.awt.event.ActionEvent evt) {
            Output.setText("1 Computer" + "\t" + 706  + "\n" ); 
            Output.append("100 Computers" + "\t" + 70600  + "\n" );
            Output.append("200 Computers" + "\t" + 141200  + "\n" );   //etc
    [/QUOTE]

  3. #3
    Member
    Join Date
    Sep 2012
    Posts
    98
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: New Line in swing

    Cannot find value append.... :s

  4. #4
    Member
    Join Date
    Sep 2012
    Posts
    98
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: New Line in swing

    Still need a little help w/ this.

Similar Threads

  1. Get points along a line in Java Swing
    By libinthomas in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 16th, 2012, 08:42 AM
  2. Replies: 10
    Last Post: September 16th, 2011, 08:49 PM
  3. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 08:34 AM
  4. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 07:32 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 07:32 AM