Solved

Writing/copying  System.out.println

Posted on 2002-05-02
7
152 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB Script to add site to Java Exception List 4 79
tomcat not starting 6 46
servlet example 11 40
Java syntax, or is it Selenium 6 16
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

832 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