[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


JTextField upper left corner

Posted on 2004-10-24
Medium Priority
Last Modified: 2006-11-17
Hi Experts!!
How can i start writing into a JTextField from the uper left Corner, and keep APPENDING?

Question by:komlaaa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 12392028
What do you mean? Sorry.
Could you elaborate a bit more? :)

LVL 24

Expert Comment

ID: 12392094
The simplest way remains:
void append(String text)
     textfield.setText(textfield.getText() + text);

You might design a strategy to add newlines as <BR>  (HTML code).
LVL 86

Accepted Solution

CEHJ earned 300 total points
ID: 12392640
It might be better to use a different component, such as JTextArea for larger amounts of text
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 30

Assisted Solution

GrandSchtroumpf earned 75 total points
ID: 12392723
I think it's better to work on the Document.
This way you don't need to set the entire text anytime you want to append something.
You just append what you need to append to the Document.
It should be much more efficient.

    JTextField myJTextField = new JTextField();
    Document myDocument = myJTextField.getDocument();

    myDocument.insertString(myDocument.getEndPosition().getOffset()-1, "hello ", null);
    myDocument.insertString(myDocument.getEndPosition().getOffset()-1, "cruel ", null);
    myDocument.insertString(myDocument.getEndPosition().getOffset()-1, "world ", null);

LVL 30

Expert Comment

ID: 12394115
LVL 86

Expert Comment

ID: 12394205

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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:
Suggested Courses

650 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