To update contents in the JTextArea

Hai all,
How to update contents in the JTextArea on changing the selection from one row to another row in JTable?Help resolve the issue.Thanks in advance.

Get the selectionModel for the JTable and add a ListSelectionListener to it. The listener is notified for changes in the row selctions in the table. You can use JTable methods inside the listeners valueChanged method to get the information you need to update your JTextArea.

Similar Messages

  • Read file from directory, update contents of the each file

    hai,
    I could not understand how to debug the error i have now.
    target
    1- read the files from directory // i able ot do this part
    2- for each file
    for each file read the content & compare with the existing List & update the list // i able to do this part
    when i try to combine both parts , i got some following error
    run:
    E:\java\check\100130.ixf
    Error: children[i] (The system cannot find the file specified)
    BUILD SUCCESSFUL (total time: 2 seconds)
    i can see from the code that children[i] only gives the error when i use that in the second part of the code.
    can any one help me on this??
    Thanks
    Priyan
    the original code
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStreamReader;
    import java.io.RandomAccessFile;
    import java.util.ArrayList;
    public class CompareList
         public static void main(String[] args){
             ArrayList a1 = new ArrayList();
             ArrayList a2 = new ArrayList();
             a1.add("1");
             a1.add("2");
             a1.add("3");
             a1.add("4");
             a1.add("5");
             a1.add("6");
             a1.add("7");
             a1.add("8");
             a1.add("9");
             a1.add("10");
             a1.add("11");
             a1.add("12");
             a1.add("13");
             a1.add("14");
             a1.add("15");
             a1.add("16");
             a1.add("17");
             a1.add("18");
             a1.add("19");
             a1.add("20");
             a1.add("21");
             a1.add("22");
             a1.add("23");
             a1.add("24");
             a1.add("25");
             a1.add("26");
             a1.add("27");
             a1.add("28");
             a1.add("29");
             a1.add("30");
             a1.add("31");
             a1.add("32");
             a1.add("33");
             a1.add("34");
             a1.add("35");
             a1.add("36");
             a1.add("37");
             a1.add("38");
             a1.add("39");
             a1.add("40");
             a1.add("41");
             a1.add("42");
             a1.add("43");
             a1.add("44");
             a1.add("45");
             a1.add("46");
             a1.add("47");
             a1.add("48");
             a1.add("49");
             a1.add("50");
             a1.add("51");
             a1.add("52");
              try{
                    File dir = new File("E:\\java\\check");
                    File[] children = dir.listFiles();
                    if (children == null) {
                          System.out.println("does not exist or is not a directory");
        else {
               for (int i = 0; i < children.length; i++) {
                       System.out.println( children);
    FileInputStream fstream = new FileInputStream("children[i]");
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine = br.readLine()) != null)      {
    String line =strLine.substring(0,2);
    // Print the content on the console
    //System.out.println(line);
    a2.add(line);
    } // end of add list2
    if (a1.size() > a2.size())
    int k = 0;
    for (int l = 0; l < a2.size(); l++)
    if (!((String)a1.get(l)).equals((String)a2.get(l)))
    //System.out.println((String)a2.get(i));
    // System.out.println("dd");
    k = l;
    k++;
    for (int l = k; l < a1.size(); l++)
    System.out.println((String)a1.get(l));
    String str = "children[l]";
    File file = new File(str);
    RandomAccessFile rand = new RandomAccessFile(file,"rw");
    rand.seek(file.length()); //Seek to end of file
    rand.writeBytes((String)a1.get(i)); //Write end of file
    rand.writeBytes("., 0.");
    rand.writeBytes("\n");
    }// end of comparing and updating the list2
              in.close();
    catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());

    thanks for the information.
    i tried, the error
    like this
    run:
    E:\java\check\100130.ixf
    java.lang.StringIndexOutOfBoundsException: String index out of range: 2
            at java.lang.String.substring(String.java:1935) 
            at CompareList.main(CompareList.java:84)
    BUILD SUCCESSFUL (total time: 0 seconds)this comes because in my code i used children[i] as string in the later part
        else {
               for (int i = 0; i < children.length; i++) {
                        System.out.println( children);
    FileInputStream fstream = new FileInputStream(children[i]);
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine = br.readLine()) != null)      {
    String line =strLine.substring(0,2);
    a2.add(line);
    System.out.println(line);
    } // end of add list2
    if (a1.size() > a2.size())
    int k = 0;
    for (int l = 0; l < a2.size(); l++)
    if (!((String)a1.get(l)).equals((String)a2.get(l)))
    //System.out.println((String)a2.get(i));
    // System.out.println("dd");
    k = l;
    k++;
    for (int l = k; l < a1.size(); l++)
    System.out.println((String)a1.get(l));
    String str = "children[l]";
    File file = new File(str);
    RandomAccessFile rand = new RandomAccessFile(file,"rw");
    rand.seek(file.length()); //Seek to end of file
    rand.writeBytes((String)a1.get(i)); //Write end of file
    rand.writeBytes("., 0.");
    rand.writeBytes("\n");
    rand.close();
    }// end of comparing and updating the list2
              in.close();
    i stil could not figure out it yet. do u have any clue with this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to save contents of a JTextArea to a file without the newline blocks?

    Hello everyone
    I have created a GUI with a JTextArea and a button to save the contents of the JTextArea to a text file. I am working on a windows platform. Problem is that when saving the contents to the file, the newline block appears within the file ignoring the newline in the JTextArea.
    Is there a way of saving these contents the way they appear in the JTextArea preserving the format they are displayed? I want to create a file that looks exactly the way my JTextArea looks like.
    Up to the moment i am using the following code which produces a rather confusing file:
    save.addActionListener(
                        new ActionListener() {
                             public void actionPerformed(ActionEvent e) {
                                  String textCaptured = textArea.getText();
                                  File file = new File("Log.txt");
                                  try {
                                       BufferedWriter out = new BufferedWriter(new FileWriter(file));
                                       out.write(textCaptured);
                                       out.flush();
                                       out.close();
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();
                                  finally{
                                       JOptionPane.showMessageDialog(null,"Your log file has been created");
              );Thank you all in advance
    Christophoros

    Thanks uncle_alice.
    Your solution worked like a charm :)
    Have a nice day
    To anyone who might face similar problems heres the code:
    File file = new File("Log.txt");
                                  try {
                                       BufferedWriter out = new BufferedWriter(new FileWriter(file));
                                       textArea.write(out);
                                       out.flush();
                                       out.close();
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();

  • Update Content and Task Sequence Changes are Slow

    ConfigMgr 2012 R2
    When choosing "Update Content" from the deployment under the Deployment Types tab, the revision number changes but the update takes about 30 minutes to complete.  When app testing this is becoming increasingly frustrating.  A change made
    and then having to wait ~30 minutes is wasting too much time.  This delay doesn't always occur. When its working quickly, the pie chart would immediately turn yellow and a few minutes later files would be updated and the Last Update: under the pie
    chart would show the current time/date.  The packages being tested are all small and being distributed to a couple local DPs over 1GB connections.  When triggering "Update Content", the distmgr.log does not display any information about
    the distribution of the files until it actually does start which as mentioned earlier starts roughly 30 minutes after triggering "Update Content".  Keep in mind it's not exactly 30 minutes.  This timeframe is variable.
    Also noticed that when an app install was set to disabled in a Task Sequence, when PXE booting, the app was still trying to run.  Sometimes an app can be changed to disabled and an immediate PXE boot will not attempt to install the app.  This also
    applies to enabling a disabled app.
    The update content issue would appear to be some type of backlog issue but disabling an app in a Task Sequence seems like it would be more like a DB transaction.  Although it seems like two issues, both issues rear their ugly head at the same
    time. 
    Any thoughts?
    Thanks

    Hi ,
    Thanks for the info. When you create a package, the files are copied from the source path to the content library on the site server. Then, the content is copied from the content library on the site server to the content library on the distribution points.
    Please also check if "Allow clients to connect anonymously" is enabled on the DP Properties. See this link:
    https://social.technet.microsoft.com/Forums/en-US/a291c1cd-ab00-47f0-a99a-6befe178dfc7/sccm-2012-r2-osd-very-slow-at-driver-package-and-config-manager-client-stage-still-after-kb2905002?forum=configmanagerosd
    http://blogs.technet.com/b/configurationmgr/archive/2010/06/03/solution-you-may-experience-slow-performance-when-using-bits-and-kerberos-authentication-on-configmgr-2007-distribution-points.aspx\
    Thanks.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Update Content Applications on a Schedule

    I have an app that is global - across many time zones.
    Is there a way to schedule updating contet to specific DP's? 
    I.E. make sure a DP in california updates at 5pm local time and that a DP in Australia also updates at 5pm local.
    I only see the option for "Update Content" on the deployment package, which immediately causes all DP's to update.

    I created a powershell script that updates the content of an application. I then called the script using a scheduled task.   This way I can run it off hours on a regular basis.  (This is great for my antivirus application source files that
    get updated definition content.)
    Import-Module ‘D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
    Set-Location XXX:
    Update-CMDistributionPoint -ApplicationName "$name" -DeploymentTypeName "$dptname"
    Make sure your path to the module is correct in the first line and that your Site code is correct in the second line.
    For the last line, put the application name and deployment type name in the right spots in the quotes.
    Here is a link to the site that shows how to run a powershell script from a scheduled task.
    http://community.spiceworks.com/how_to/show/17736-run-powershell-scripts-from-task-scheduler 

  • How to get the content of a jTextArea?

    hi everyone
    can some body provide me with some help???
    I want to know how to get the content of a jTextArea
    it may be a String and i want to use that String to make some applications
    I've use this :
    String ch=jTextArea.getSelectedText()
    but i'm not sure it will work and i'm not sure it will take the text writen inside the jTextArea ... please help
    Thanks

    http://forum.java.sun.com/thread.jspa?threadID=778988&tstart=0

  • How do I update my iPad to ios5 I am getting an error mesage -402653081 while backing up the iPad, if I proceed then I will loose all the content of the iPad?

    How do I update my iPad to ios5 I am getting an error mesage -402653081 while backing up the iPad, if I proceed then I will loose all the content of the iPad?

    The IOS5 upgrade will erase everything on your iPad, so make sure you have a good backup before you start.
    If not, you will just have to reenter all of your settings all over again.  Have you ever backed it up successfully?

  • Update the database table with the content of the internal table

    Hello!
      I have the next form:
      FORM erase_data.
    SELECT * FROM zadrress INTO CORRESPONDING FIELDS OF TABLE itab_adrress.
      DELETE TABLE itab_adrress: FROM zadrress,
                                 WITH TABLE KEY adrid = '456'.
      WRITE 'The information after the DELETE operation'
      COLOR 2.
      LOOP AT itab_adrress INTO wa_adrress .
        WRITE:/
               wa_adrress-adrid COLOR 5,
               wa_adrress-name COLOR 7,
               wa_adrress-email COLOR 5,
               wa_adrress-depart COLOR 7,
               wa_adrress-display COLOR 5.
      ENDLOOP.
      SKIP.
    LOOP AT itab_adrress INTO wa_adrress.
       MODIFY zadrress FROM wa_adrress.
       COMMIT WORK.
       IF sy-subrc = 0.
         WRITE 'OK !'.
         SKIP.
       ELSE.
         WRITE 'FAIL !'.
         SKIP.
       ENDIF.
    ENDLOOP.
      MODIFY zadrress FROM TABLE itab_adrress.
      UPDATE zadrress FROM TABLE itab_adrress.
    TRANSPORTING adrid, name, email, depart, display.
    INSERT zadrress FROM TABLE itab_adrress ACCEPTING DUPLICATE KEYS.
    PERFORM display_data .
    ENDFORM.                    "erase_data
    I see that my record is deleted  when I display the records from my internal table, but
    now I want to delete the record from database table.
       For that I want to move the content of the modified internal table in the database table. You can see the methods I tried (some of them commented), but nothing seems to work.
    Any advice ?
    Thank you.

    FORM erase_data.
    SELECT * FROM zadrress INTO CORRESPONDING FIELDS OF TABLE itab_adrress.
    DELETE TABLE itab_adrress: FROM zadrress,
    WITH TABLE KEY adrid = '456'.
    WRITE 'The information after the DELETE operation'
    COLOR 2.
    LOOP AT itab_adrress INTO wa_adrress .
    WRITE:/
    wa_adrress-adrid COLOR 5,
    wa_adrress-name COLOR 7,
    wa_adrress-email COLOR 5,
    wa_adrress-depart COLOR 7,
    wa_adrress-display COLOR 5.
    ENDLOOP.
    SKIP.
    LOOP AT itab_adrress INTO wa_adrress.
    MODIFY zadrress FROM wa_adrress.
    COMMIT WORK.
    IF sy-subrc = 0.
    WRITE 'OK !'.
    SKIP.
    ELSE.
    WRITE 'FAIL !'.
    SKIP.
    ENDIF.
    ENDLOOP.
    <b>DELETE FROM zadrress.</b>  "Make this change and try
    MODIFY zadrress FROM TABLE itab_adrress.
    UPDATE zadrress FROM TABLE itab_adrress.
    TRANSPORTING adrid, name, email, depart, display.
    INSERT zadrress FROM TABLE itab_adrress ACCEPTING DUPLICATE KEYS.
    PERFORM display_data .
    ENDFORM. "erase_data'.

  • Can you delete the contents of the Updates folder?

    Hi,
    Trying to free up some space on my hard drive. Using OmniDiskDweeper app. Just wondering if it's safe to delete the contents of the Updates folder; the one located in the hard drive/library. There is about 5 GB of stuff in there.
    thanks,
    J

    Jaymo, I deleted the contents of my "Updates" folder on my MBPro2.2 without any ill-effects.

  • Update some of the content of a page

    I want to to allow a colleague to update some of the content
    of a page without giving them access to change the whole page.
    How can I do this without using Contribute?

    "David Powers" <[email protected]> wrote in message
    news:f81uqh$sfr$[email protected]..
    > stretchbreak wrote:
    >> How can I do this without using Contribute?
    >
    > Use a server-side include. The changing content can then
    be a simple text
    > file. If your site uses a server-side language, such as
    PHP, includes are
    > automatically supported.
    And even if it doesn't support a server-side language,
    regular SSIs may be
    supported - ask your host.
    Patty Ayers | Adobe Community Expert
    www.WebDevBiz.com
    Free Articles on the Business of Web Development
    Web Design Contract, Estimate Request Form, Estimate
    Worksheet

  • Updating content on return from the portlet edit URI

    I have written a portlet with a pageflow content URI and a pageflow edit URI. The
    content URI pageflow displays some formatted data obtained from a combination
    of portlet preferences and database records. The edit URI pageflow allows the
    user to add records to the display, delete records from the display, or re-format
    the displayed records. The edit URI pageflow is executed by clicking the “edit”
    button on the portlet titlebar.
    The problem is when I click the “Leave Edit” button on the portlet titlebar and
    return to the content page, the display is not updated to show the additions,
    deletions, or re-formats performed by the user in the edit URI pageflow. The user
    must log out and log back in to see the changes.
    How can I cause the portlet to re-execute the begin action on it’s content URI
    pageflow when returning from the edit URI pageflow so the user doesn’t need to
    log out and log back in?

    Heay.....this worked for me.
    I am able to change the mode programatically from edit to show.
    HttpPortletRendererUtil.handleEditAction(portletRenderRequest,"OK");
    I removed Apply , OK and Cancel buttons and applied my own Submit and Back button in Personalize mode and then change the mode to show on click of Back button using the above mentioned statement.
    Thanks
    ~Neeraj Sidhaye
    Try_Catch_Finally @ Y !
    ExtremePortal @ Gmail&#12288;&#65316;&#65359;&#65364;&#12288;&#65315;&#65359;&#65357;

  • Click a row in jTextArea and get the content of the row.

    I have an array of strings display in a textarea, once a user click on a row, i will like to display the content of the clicked row. I am new in java swing. how should i achieve it? thank you all!!

    Working example with CaretListener:
    package org.apex.sunforums;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    * TextAreaLineSelectionTest.java
    * @author mrityunjoy_saha
    * @version 1.0
    * @since Apex 1.2
    public class TextAreaLineSelectionTest {
        public void createUI() {
            final JFrame frame = new JFrame("TextAreaLineSelectionTest");
            frame.setSize(400, 400);
            JPanel panel = new JPanel();
            panel.setLayout(new GridLayout(2, 1));
            final JTextArea textField = new JTextArea(
                    "Hello\nThis is a test class.\nTo show line selection\nType some text and see the magic.",
                    10, 20);
            JScrollPane scroll = new JScrollPane(textField,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            final JLabel display = new JLabel();
            textField.addCaretListener(new CaretListener() {
                public void caretUpdate(CaretEvent e) {
                    String lineText = "";
                    try {
                        int dot = e.getDot();
                        int rowStart = Utilities.getRowStart(textField, dot);
                        int rowEnd = Utilities.getRowEnd(textField, dot);
                        lineText = textField.getDocument().getText(rowStart,
                                (rowEnd - rowStart));
                    } catch (BadLocationException ex) {
                        ex.printStackTrace();
                    display.setText(lineText);
            panel.add(scroll);
            panel.add(display);
            frame.getContentPane().add(panel);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        public static void main(String[] args) {
            final TextAreaLineSelectionTest test = new TextAreaLineSelectionTest();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    test.createUI();
    }Thanks,
    Mrityunjoy

  • Displaying only the updated contents

    i am working with jsp ,is there any way i can display only the updated contents of a form ie suppose a user updated 2 fields out of possible 10 fields i want to display only those 2 fields not all the 10,i am using mysql data base,can any one give a reply

    Compare the new value with the old value. If it differs, then it is changed. For primitives you can use == to compare and for objects you can use Object#equals() to compare.

  • How to save the content of a JTextArea into a txt file?

    Hi, I want to save the content of a JTextArea into a txt file line by line. Here is part of my code(catch IOException part is omitted):
    String s = textArea.getText();
    File file = new File("file.txt");
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    bw.write(s);
    bw.close();
    But I found in the file all is binary code instead of text, any people can help me?
    Thanks in advance

    I can see text in the file now, but the problem is
    when I write three lines in textarea, for example
    111
    222
    333
    then I open the txt file with notepad, it is
    111222333
    How to save them line by line? Use a PrintWriter. It lets you write lines (it's the same class as System.out).
    http://java.sun.com/j2se/1.4/docs/api/java/io/PrintWriter.html

  • Final Cut Pro X after installing Mountain Lion I have lost some of the "additional content" which was available by clicking on "Download Additional Content" in the roll down from "Final cut Pro". Now this feature takes you to store update?

    Final Cut Pro X after installing Mountain Lion I have lost some of the "additional content" which was available by clicking on "Download Additional Content" in the roll down from "Final cut Pro". Now this feature takes you to Apple store update? which produces nothing! How can I download these free sound and music files, what has happened? Please help as there is nothing on the apple site to cover this??

    Final Cut Pro X after installing Mountain Lion I have lost some of the "additional content" which was available by clicking on "Download Additional Content" in the roll down from "Final cut Pro". Now this feature takes you to Apple store update? which produces nothing! How can I download these free sound and music files, what has happened? Please help as there is nothing on the apple site to cover this??

Maybe you are looking for

  • Getting error while reading Task Notes

    Hi, I have a problem while opening the task from UWL. It is about reading task notes. One LDAP User had written a note previous task but now this user is deleted from LDAP. So the task screen trying to read this user while getting notes and throws ex

  • PDF Preview working intermittently from workspace for FR reports

    We are facing a strange issue while running HFM reports from workspace and taking PDF Preview, the report runs fine but when going for the PDF preview we dont get it every time. Some it works when we try again by clicking on PDF preview button again,

  • MAGENTO WEBSITE AND SAFARI (Mac only) BUG.

    I seem to be finding that my new website does not work with Safari 4.0.5 on a mac running OSX 10.4.11 Cookies will not enable (checked preferences) You cannot log in. You cannot add items to basket or shop. I don't see who is at fault and why it work

  • Dropped frames caused from slow disks (Disk Speed)

    I just bought a hard drive enclosure that holds double hard drives. http://www.ewiz.com/photogallary.php?name=CA-400MXS2&show=g Inside the enclosure I put two 400G Seagate SATA drives and made them both scratch drives for my FCE 4 projects. Now when

  • Can videos be retrived after it has been deleted and factory reseted

    is there such thing as retrieving videos software after you have deleted and restored your ipod back to factory settings