Solved

Writing/copying  System.out.println

Posted on 2002-05-02
7
151 Views
Last Modified: 2010-03-31
Hi All,

I have JBuilder5, personal edition, and I want to show and copy what I see in output of the applet now using  System.out.println("StringWhatEver");

I know how to use and can see it in:
   
public void paint(Graphics g) {
g.setColor(Color.blue);
g.drawString("StringWhatEver", 150, 10);
}

I want to show it inside a scroll box  in an applet so that the user  can higlight the outout  and copy the information.
A small example would be appreciated.

Delphi3





0
Comment
Question by:delphi3
  • 4
  • 3
7 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 50 total points
ID: 6986219
why not put a textarea on the applet and do something like:
TextArea myTextArea = new TextArea("StringWhatever", 5, 10, TextArea.SCROLLBARS_VERTICAL_ONLY);
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6986228
and if you want to copy some selected text:

String strText = myTextArea.getSelectedText();
0
 
LVL 4

Author Comment

by:delphi3
ID: 6987656
bobbit31,

I have tried your answer and I have tried to extend it to include more than one text line.


I have used myTextArea.append to write the next line. What results is that the next line is not left justified and if copied shows the entire text as a single string. Is there a command to get it to be left justified in the second line, so that the next line and the one above it are on seperate lines?

Delphi3
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:delphi3
ID: 6987812
bobbit31,
 
Got it!!
 
This thing "\n" causes the next line to be left justified as in:
myTextArea.append("First String");
myTextArea.append("\nSecond String");

And now after a run, a higlight over the text in the applet text area and a control 'c',then pasting it into a .txt form shows that each line is now left justified.

Delphi3
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6987831
the \n is a new line character.

but anyway, i take it it's working now? if so, glad to hear it!
0
 
LVL 4

Author Comment

by:delphi3
ID: 6987896
Yes it is working fine and I thank you very much for stopping by and helping out.

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
ID: 6987899
Thanks again,


Delphi3
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange loading of website behaviour 3 31
mockito example issue 8 62
simple java question 3 43
even odd program using while loop 3 19
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now