How to dynamicly scroll a text area?

Hi,
i put my JTextArea on top of a JScrollPane.
i want to set the JScrollPane scroll to the end of the JTextArea everytime i do textArea.append(someString);
is there an easy way of doing this? or i have to program the logic?
Thanks.

This question has probably been asked a hundred times. The default behaviour is for the textare to scroll automatically if the following conditions are met:
a) the caret is at the end of the document
b) the append is done from the event thread
If you want more adice then try searching the forum. Using keywords "jtextarea scrolling" would be a good place to start.

Similar Messages

  • How to dynamically change the text of a TextObject with embedded DataField?

    Hi
    I'm trying to dynamically change the text of a TextObject at runtime, by using the .NET library. My problem is that if one or more DatabaseFieldDefinition is embedded inside my text, I'm unable to change the "static text" only, by keeping the field, e.g. I have :
    Text1 => "Contact Name: {Contact.Name}"
    and I'd like to change it to anything else like:
    Text1 => "Nom du Contact: {Contact.Name}"
    Half of my TextObject is static text while second part comes from the dataset.
    (of course the translation is dynamic - it is called at run-time and the new value to be set depends on the calling application language)
    If I simply modify the Text property of my TextObject, the {Contact.Name} embedded field is not evaluated anymore by the Crystal Engine, but considered as a single text.
    Using formulas or parameters looks quite difficult, because it means having many ones just for translation needs - I cannot control the way my users will create their reports and "force them" to use complex methods just in order to put a text and a value together...
    Anyone knows how to deal with that ?

    Only way I can think of doing this:
    1) Create a formula (call it lang) and enter the string "Contact Name" in it
    2) Place the  {Contact.Name} field next to the string
    3) So now you have:
    ContactName:  {Contact.Name}
    4) Check what localization you are after. If you need "Nom du Contact", change the lang formula so it shows "Nom du Contact" using the code below:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim Report As New CrystalReport1()
    Dim FormulaFields As FormulaFieldDefinitions
    Dim FormulaField As FormulaFieldDefinition
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    FormulaFields = Report.DataDefinition.FormulaFields
    FormulaField = FormulaFields.Item(0)
    FormulaField.Text = "[formula text]"
    CrystalReportViewer1.ReportSource = Report
    End Sub
    I realize this may not give you consistent spacing as the translations may have strings of differnt length. Perhaps someone has other idea(s)...

  • How to Align test in Text Area?

    Someone please show me how to align text in text Areas...

    You can't (not without rewriting major portions of JTextArea)
    Here's a link which may help (use JTextPane instead)
    http://forum.java.sun.com/thread.jsp?forum=57&thread=342068
    http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20258546.html

  • Controlled scrolling in Text area

    Hi
    Given a particular offset in Textarea.text, I want to scroll
    the Textarea instance to a vPosition where the word will be
    displayed. The height, width, fontsize, fonttype for the text area
    is fixed and it has only plain text associated with it.
    e.g. I want to make sure that word "WORDTOSHOW" is displayed
    in the visible area of textarea.
    "The quick brown fox jumps over the little lazy dog.
    WORDTOSHOW. This is a sample text".
    I have tried several heuristics e.g. assuming fixed number of
    characters in a line but they fail in several test cases.
    HB

    Sure? Please, can you try this?
    Go to this webpage:
    http://web.me.com/choprats/ONLINE
    You can try to view and scroll an iFRAME and an OBJECT. With Safari, Firefox or Chrome on my Mac there is no problem, but I can't view correctly the iFRAME height on Safari mobile, and is not possible to scroll the Object inserted.

  • How can I disable resizeable text areas?

    In the beta version, I noticed you added a resize option for multiline text areas. How can I disable this for all the users on my website? Is there something I can write in my CSS to disable it?

    See:
    *http://dev.l-c-n.com/form-controls/resize_textarea.html
    <pre><nowiki>textarea {resize:none}</nowiki></pre>

  • Forgot how to format HTML  in Text Area

    Hello all,
    I totally forgot something. How do you format HTML when rendering in Text area
    Suppose I pass in a string that a text area grabs for display.
    xxx.getAdditionalComments(existingComments + "\n"  +  "<B>" + date + "<\B> " + name);The text are will always display the <B> instead of displaying the date in bold.
    I remember putting escape characters eons ago but I forgot how that worked. Anyone know how to render this with date being bolded?
    Thanks.

    If you mean the textarea HTML tag for text entry fields, you don't. If you forgot anything it's that you can't do things like that.

  • How to capture data of text area

    Hello Experts,
            I have added a text area to a home page using the tag as below
    <textarea id="recipient_list" rows="5" cols="40" name="recipients"></textarea>
    I expect this text area to be populated at runtime. I want to use the data entered in this text area in one of the methods. But I do not know how to capture the data.
    Could you please help me by telling me the way that will make this data available for use in a method of implementation class?
    Regards,
    Prafful

    Hello Prafful,
    In general, you need to connect your text area with a context. So, you need to create a value context node with an attribute which will store the entered text. Then, you need to link you text area with this attribute.
    Best Regards,
    Yevgen

  • How to add document header text area on fb03's selection screen

    hi,
    i want to add an additional area on fb03's selection screen. i need document header text area for my document searchs. is it possible?

    Refer to this thread
    How to Add field to Selection screen of Tx. FBL5N

  • How to put smiley in text area?

    Well, I am developing chat application, and I want to know
    how to put smilies in some sort of text area, either movie clips or
    bitmaps? I know that you can use <img> tag, but picture is
    never in line with the text, it always looks wrong.
    Sorry if that's been answered before, but I couldn't find
    it.

    I too am trying to accomplish this, although for a different
    purpose. Any suggestions would be greatly appreciated.

  • How to validate characters in text area

    Hello gurus!
    I have a doubt in how to allow a user to only write numbres or lettrs in a text area. I'm looking in the VC options for some time and cannot find a clue. Any ideas?
    Regards

    If you are getting this 32K error for this field then you would get it for regular expression too. You may have to remove few unused field from your model in order to successfully deploy this. You can delete the fields that not used and try deploying again.
    OR
    You can try deploying using the FLEX 2 Compiler.
    Regards,
    Murtuza

  • How to get a adf text area width using javascript

    hi
    i have to catch different input text width(i.e 30px,500px.etc) dynamically using javascript(adf:clientListner)
    Thanks and regard
    B.Maheswara Reddy

    Hi,
    its af:clientListener, not adf:clientListener.
    af:clientListener passes an event to the JavaScript method
    function getWidthOfComp(event){
    alert(event.getSource().getWidth());
    }

  • How do you clear a text area?

    any know how to do this?

    Just like you've been told earlier... Either add an actionlistener to the textarea that invokes its method JTextArea.setText("") or add a listener to a button and include the method that causes this as well.

  • How to middle text in a text area?

    Can someone tell me how to middle the text (vertically) on a JTextArea? It always starts at the top.
    Thanks to all in advance
    sridhar

    Um, assuming by "middle the text" you mean scroll the text area to the vertical center of the text area:
    1) Enclose your text area in a JScrollPane.
    2) Get the vertical scroll bar of the scroll pane using:
    JScrollBar scrollbar = scrollpane.getVerticalScrollBar();3) Find the middle of the scroll bar using:
    scrollbar.setValue(scrollbar.getMaximum() / 2);

  • How to add a text area in a Content pane..?

    Hi,
    I created a content pane with 5 buttons. One of them is a quit button, and I was able to create an "system.exit(0)" event handling for him. My problem is.. I have 4 other buttons, and I want them to show some text when I click them. How do I add a text area bellow my content pane..?
    Copy/paste my code to see what im talking about :) :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Interface extends JFrame {
    public Interface() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    JButton button1 = new JButton("Test1");
    JButton button2 = new JButton("Test2");
    JButton button3 = new JButton("Test3");
    JButton button4 = new JButton("Test4");
    JButton button5 = new JButton("Quit");
    ButtonHandler handler = new ButtonHandler();
    button5.addActionListener( handler );
    contentPane.add(button1);
    contentPane.add(button2);
    contentPane.add(button3);
    contentPane.add(button4);
    contentPane.add(button5);
    contentPane.setBackground(Color.orange);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public static void main(String args[]) {
    Interface window = new Interface();
    window.setLocation(250,350);
    window.setTitle("FlowLayout");
    window.pack();
    window.setTitle("Test");
    window.setVisible(true);
    public class ButtonHandler implements ActionListener {
    public void actionPerformed( ActionEvent e )
    System.exit(0);
    Thanks alot! :)

    By default the content pane of the JFrame uses a Border Layout. So you should:
    1) Create a JPanel
    2) Set the layout of the JPanel to FlowLayout
    3) add the buttons to the panel
    4) add the panel to the content pane
    5) add your text area to the content pane
    Read this section from the Swing tutorial on "Using Layout Managers":
    http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

  • How to add box around text in s:TextArea?

    Hi,
    What I want to do is I want a red box to appear around some text in my s:TextArea, which is editable.
    Well, I can add a red box by putting the following after my text area.
      <s:Graphic>
        <s:Rect x="20" y="110" width="20" height="20" >
             <s:stroke>
                  <s:SolidColorStroke color="0xFF8888"/>
             </s:stroke>
        </s:Rect>
      </s:Graphic>
    However the user will edit the text, and the text position will change. Also the user will scroll the text area up and down.
    So the location of the box should move to still be located around the text.
    How can I track the position of the text? Is this a good idea? to track the position of the text and to keep moving the box to keep it on top of the text?
    Thanks, Philip

    Philip,
    How about something like this?
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/halo">
        <s:TextArea id="txtArea"
                horizontalCenter="0" verticalCenter="0">
            <s:content>
                <s:p>The quick brown fox jumps <s:span backgroundColor="0xFF0000" backgroundAlpha="0.8">over</s:span> the lazy dog.</s:p>
            </s:content>
        </s:TextArea>
    </s:Application>
    Peter

Maybe you are looking for

  • I updated Apple Configurator to 1.3 and my database isn't migrating.

    I updated Apple configurator to 1.3 from 1.2.1 and the database isnt migrating, it crashes during the process. When i use time machine to go back to before the update it starts trying to migrate again it doesnt revert it to 1.2.1 . When i try and rev

  • Itunes has stopped working Vista - ntdll.dll problem

    Hi, I've been having a problem with my itunes for the last month or so... Whenever I try to open itunes, it comes up with the "itunes has stopped working" message and won't open.  This is the problem data I found. Problem Event Name:          APPCRAS

  • Can I fax a pdf instead of email it?

    I need to fax a scanned and saved pdf from adobe to a governmental agency that does not have email.  Can i fax a document from adobe?

  • Photoshop Elements 13 is not responding

    I have downloaded Photoshop Elements 13 and when I go to extract files it almost completes and then it says Photoshop Elements 13 is not responding.  What can I do to fix this?

  • Does update all restore all my deleted apps?

    I have downloaded tons of apps, but have also deleted many of them to make space in my phone. If I "update all" alls from the App Store, will this update only the apps that are installed (and not deleted) on my phone?  or will it also reinstall all t