Results 1 to 6 of 6

Thread: Swing Problems

  1. #1
    niba10 is offline Member
    Join Date
    Feb 2011
    Posts
    30
    Rep Power
    0

    Default Swing Problems

    Hi I built a GUI with SWING and I have scroll pane in jtextarea
    now what I want to do is when i enter text it will scroll down Automatic
    and the second problem is with Jtextfield I type text in the field and then
    I click on a button and the text print on the jarea but I want the marker still
    be on the jtextfield

    :confused:

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,517
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by niba10 View Post
    Hi I built a GUI with SWING and I have scroll pane in jtextarea
    now what I want to do is when i enter text it will scroll down Automatic
    and the second problem is with Jtextfield I type text in the field and then
    I click on a button and the text print on the jarea but I want the marker still
    be on the jtextfield

    :confused:
    On the JTextArea get the caret and set its: caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE) so that the text will scroll after you've appended text and scrolling is necessary.

    Also, after an append to the JTextArea requestFocus on your JTextField.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    niba10 is offline Member
    Join Date
    Feb 2011
    Posts
    30
    Rep Power
    0

    Default

    u tried this and its not work
    :
    Caret caret = area1.getCaret();
    caret(DefaultCaret.ALWAYS_UPDATE);
    area1.setCaret(caret);
    and for jtextfield type this:
    area1.setNextFocusable(text1);

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,517
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by niba10 View Post
    u tried this and its not work
    :


    and for jtextfield type this:
    area1.setNextFocusable(text1);
    Nobody mentions the setNextFocusable( ... ) method; reread my reply; also it is not necessary to set the Caret again, i.e. your JTextArea already has it. Also also, telling us that 'it doesn't work' isn't telling us much.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    niba10 is offline Member
    Join Date
    Feb 2011
    Posts
    30
    Rep Power
    0

    Default

    pls tell me the code i dont know what to do i tried every thing..

  6. #6
    niba10 is offline Member
    Join Date
    Feb 2011
    Posts
    30
    Rep Power
    0

Similar Threads

  1. InputStream/Jar Problems/File IO Problems
    By rdjava in forum Advanced Java
    Replies: 31
    Last Post: 01-17-2011, 11:12 AM
  2. Replies: 13
    Last Post: 12-06-2010, 05:57 AM
  3. Swing
    By tmotse in forum AWT / Swing
    Replies: 0
    Last Post: 03-31-2010, 10:18 AM
  4. swing.jar
    By krrishnak in forum AWT / Swing
    Replies: 2
    Last Post: 04-05-2009, 05:29 AM
  5. map javax.swing.text.Element to javax.swing.text.View
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 07:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •