JTextArea can't append

I need to append text to a JTextArea from a different class than the JTextArea is in. For example, my code is as follows:
public JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new java.awt.Rectangle(115,8,274,181));
jTextArea.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
jTextArea.setText("Chat initiated...");
jTextArea.append("append");
          return jTextArea;
Appending the text works in the above code, but if I try to append text using this code:
jTextArea.append("appended text");
anywhere else in the code it will not work. Why is this and how do I append text to the jTextArea?

You can't expect one class to recognize a variable declared elsewhere, right?
class Freader {
    public static void main(String args[]){
        jTextArea.append("new text"); //out of nowhere!
}This really isn't a Swing question, it's a "how can I write code" question.
To send message append (for example) to object jTextArea
and do this from within method m of class C, then either:
1. Create the object referred to by jTextArea in method m.
2. Have jTextArea passed into method m
3. Have jTextArea be a field of class C
4. Invoke some other method that returns the reference to jTextArea.
5. Don't do this directly in m: invoke another method that does
it directly or indirectly.
Do you get the idea?
For example, Below I define Main, which will invoke append, and Display,
which has the append method.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main {
    public static void main(String[] args) {
        final JFrame f = new JFrame("Main");
        JButton btn = new JButton("append");
        btn.addActionListener(new ActionListener(){
            Display display = new Display(f);
            public void actionPerformed(ActionEvent evt) {
                display.append("some more text\n");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(btn);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
class Display {
    public Display(JFrame owner) {
        JDialog dialog = new JDialog(owner, "Display");
        textComponent = new JTextArea(20, 50);
        dialog.getContentPane().add(new JScrollPane(textComponent));
        dialog.pack();
        dialog.setVisible(true);
    public void append(String text) {
        textComponent.append(text);
    private JTextArea textComponent;
}

Similar Messages

  • Can I append the text in JEditorPane?

    Hi,
    I can do append text into JTextArea e.g.
    textarea.append(string);
    but in JEditorPane, it only support setText()
    setText() will replace the existing text with the new text but not appended.
    Any ideas?
    thanks.

    Document doc=jep.getDocument();
    doc.insertString(doc.getLength(), stringToInsert, null/*or whatever*/);

  • How can i append the variable to filename in import statement?

    how can i append variable(substitution variable) to file name in import command for maxL?
    example : For suppose there is a file like "dataload.txt" and a variable like cur_month(august).How can i rename the file like daload_august in import statement.
    Edited by: 788996 on Aug 22, 2010 11:18 PM

    Are you saying you want to use an OS level environment variable in a MaxL statement to substitute for an entire file name? I am going to illustrate Windows, but do it your own way in *nix if you want.
    YourCallingCode.cmd
    REM Note the \\ and then the \\, you had \\ and \
    SET curmon=c:\\ABC\\datafile_21_AUG.txt 
    REM Call MaxL with a paramenter
    startMaxL.cmd DoItForTheCurrentMonth.msh %curmon%DoItForTheCurrentMonth.msh
    login blah blah for blah ;
    import database appname.dbname data from local text data_file $curmon using server rules_file "rulefile"
         on error abort ;The trick is to change whatever's in % and % and replace it with a $ in the MaxL script.
    I gave a presentation last year on MaxL at ODTUG Kaleidoscope. If you go to http://www.odtug.com, then Tech Resources, then Essbase, then search on my name, you'll find "Master Essbase with MaxL Automation". More than you could ever want to know about MaxL, variables (parameter, environment, and explicitly declared), scripting, etc., etc., are all there for the taking. If you're not already a member, you'll have to join, but an associate membership is free. You can then download my presentation and all of the others. It is a treasure chest of technical tips and knowledge.
    Yes, I am a fan a member of the Hyperion SIG, so I am ever so slightly biased. Regardless, it is good information, for free.
    Regards,
    Cameron Lackpour
    Edited by: CL on Aug 24, 2010 5:33 AM
    If you want to substitute part of the data file name, you can do that too:
    set curmon=21_AUG
    Your MaxL statement would look like:
    import database appname.dbname data from local text data_file "c:\\ABC\\datafile_$curmon.txt" using server rules_file "rulefile"
         on error abort ;

  • How can we append data in existing flat file

    how can we append data to a existing flat file (Text file).

    just fill the itab from data which suppose to append to text file.than read text file from GUI_UPLOAD and loop on itab and with the use of read statements you may append the data.

  • External Table which can handle appending multiple csv files dynamic

    I need an external table which can handle appending multiple csv files' values.
    But the problem I am having is : the number of csv files are not fixed.
    I can have between 2 to 6-7 files with the suffix as current_date. Lets say it will be like my_file1_aug_08_1.csv, my_file1_aug_08_2.csv, my_file1_aug_08_3.csv etc. and so on.
    I can do it by following as hardcoding if I know the number of files, but unfortunately the number is not fixed and need to something dynamically to inject with a wildcard search of file pattern.
    CREATE TABLE my_et_tbl
      my_field1 varchar2(4000),
      my_field2 varchar2(4000)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY my_et_dir
         ACCESS PARAMETERS
           ( RECORDS DELIMITED BY NEWLINE
            FIELDS TERMINATED BY ','
            MISSING FIELD VALUES ARE NULL  )
         LOCATION (UTL_DIR:'my_file2_5_aug_08.csv','my_file2_5_aug_08.csv')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;Please advice me with your ideas. thanks.
    Joshua..

    Well, you could do it dynamically by constructing location value:
    SQL> CREATE TABLE emp_load
      2      (
      3       employee_number      CHAR(5),
      4       employee_dob         CHAR(20),
      5       employee_last_name   CHAR(20),
      6       employee_first_name  CHAR(15),
      7       employee_middle_name CHAR(15),
      8       employee_hire_date   DATE
      9      )
    10    ORGANIZATION EXTERNAL
    11      (
    12       TYPE ORACLE_LOADER
    13       DEFAULT DIRECTORY tmp
    14       ACCESS PARAMETERS
    15         (
    16          RECORDS DELIMITED BY NEWLINE
    17          FIELDS (
    18                  employee_number      CHAR(2),
    19                  employee_dob         CHAR(20),
    20                  employee_last_name   CHAR(18),
    21                  employee_first_name  CHAR(11),
    22                  employee_middle_name CHAR(11),
    23                  employee_hire_date   CHAR(10) date_format DATE mask "mm/dd/yyyy"
    24                 )
    25         )
    26       LOCATION ('info*.dat')
    27      )
    28  /
    Table created.
    SQL> select * from emp_load;
    select * from emp_load
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    SQL> set serveroutput on
    SQL> declare
      2      v_exists      boolean;
      3      v_file_length number;
      4      v_blocksize   number;
      5      v_stmt        varchar2(1000) := 'alter table emp_load location(';
      6      i             number := 1;
      7  begin
      8      loop
      9        utl_file.fgetattr(
    10                          'TMP',
    11                          'info' || i || '.dat',
    12                          v_exists,
    13                          v_file_length,
    14                          v_blocksize
    15                         );
    16        exit when not v_exists;
    17        v_stmt := v_stmt || '''info' || i || '.dat'',';
    18        i := i + 1;
    19      end loop;
    20      v_stmt := rtrim(v_stmt,',') || ')';
    21      dbms_output.put_line(v_stmt);
    22      execute immediate v_stmt;
    23  end;
    24  /
    alter table emp_load location('info1.dat','info2.dat')
    PL/SQL procedure successfully completed.
    SQL> select * from emp_load;
    EMPLO EMPLOYEE_DOB         EMPLOYEE_LAST_NAME   EMPLOYEE_FIRST_ EMPLOYEE_MIDDLE
    EMPLOYEE_
    56    november, 15, 1980   baker                mary            alice     0
    01-SEP-04
    87    december, 20, 1970   roper                lisa            marie     0
    01-JAN-99
    SQL> SY.
    P.S. Keep in mind that changing location will affect all sessions referencing external table.

  • How can  i append a field directly to xtract structure.

    (with out going to communication structure) while doing xtraction, if i hv a requirement to append a field directly to xtract structure. how can i append that field.

    hai satish,
    Follow these steps:
    go to rsa6 --> select your data source --> double click on the it --> double click on extract structure  --> Click on append structure.
    enter ur Enhancing Field names,
    go back to rsa6 in change mode---> remove hide check for newly added field..
    now go to se37 ---> EXIT_SAPLRSAP_001(for transaction data )
    Ur having some Include program Modify according to Ur fields.
    Thanks,
    kiran.

  • How can I append multiple parts to NetStream with appendBytes

    Hi,
    I hope  someone can help me.
    Problem:
    I load a flv file with the FileReference class. After that I append a part of the ByteArray to  the NetStream with appendBytes.
    Later I want a next part append to the NetStream. It doesn't work.
    Is that possible?
    Code:
              public function init():void
                    myFileRef = new FileReference();
                    myFileRef.addEventListener(Event.SELECT, selectFile);
                    myFileRef.addEventListener(Event.COMPLETE, playFile);
                    myOpenButton.addEventListener(MouseEvent.CLICK,browserForFile);                        
                private function browserForFile(e:MouseEvent):void
                    myFileRef.browse([new FileFilter("Flash-Videos (*.flv)", "*.flv;")]);
                private function selectFile(e:Event):void
                    myFileRef.load();
                private function playFile(e:Event):void
                    byteArr = myFileRef.data;
                    var bytes:ByteArray = new ByteArray();
                    byteArr.readBytes(bytes, 0, 3031964);
                    _netConnection = new NetConnection();
                    _netConnection.connect(null);            
                    ns = new NetStream(_netConnection);
                    ns.addEventListener(NetStatusEvent.NET_STATUS, netStreamStatusHandler);
                    ns.client = new Object();
                    display.attachNetStream(ns);
                    ns.play(null);
                    ns.appendBytes(bytes);
                    videoDisplay.addChild(display);
                private function loadNext():void
                    var bytes:ByteArray = new ByteArray();
                    byteArr.readBytes(bytes, 3031964, byteArr.bytesAvailable);
                    ns.appendBytes(bytes);
    friendly
    Daniel

    Enable the menu bar with Ctrl+B. Then use File > Add Folder to Library.
    tt2

  • Can I append the file name from a Foreach Loop Container Enumerator into a SQL Server Statement?

    I would like to pass back via an Email the name of the file that was successfully FTP'ed to a remote server. And I was hoping to do this via an Execute SQL Task with the following SQL Statement...but I just don't know if it will append the Foreach Loop Container
    variable enumerator to the appended Email message that I am building in SQL Server or if I can and how I can...
    I sort of get the feeling that I can try and do this via Dynamic SQL...I just don't know if by building dynamic SQL if my Foreach Loop Container enumerator variable will be appended to my Email Message via the SQL Server UPDATE 
    @[User::FTPFHFileName]
    Or do I add a Data Flow Task and an OLE DB Command and pass the Foreach Loop Container enumerator variable to a Stored Procedure referenced in the OLE DB Command via a "?"
    Thanks for your review and am hopeful for a reply.

    Hello,
    It seems that the issue had been solved and thanks for your sharing. It will be very beneficial for other community members who have similar questions.
    I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings or concerns you may have.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How can I append some data to an array via a case structure?

    Basically i want to do the following thing:
    do
    if control=0
    else
    Data=Data append data1
    end if
    }while(run=1)
    We try to avoid local variable since the size of Data is pretty big. I am pretty sure i can add a shift register in a loop structure.But is it possible to add a shift register in a case structure?
    Thank you!

    The best you will be able to do is going to be a variation on what CC suggested regarding replacing array sub-sets.
    If you do not know how big it will end up then over-allocate but still use the replace array subset.
    The delays you are seeing are due to the memory buffers groing and additional memory need allocated as the array grows. The Replace array subset function operates inplace and re-uses the buffer it is passed. There is no clear KB regarding which array operations operate inplace and which do not.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=74847&requireLogin=False
    Under Tools >>> Advanced >>> Show buffer allocations will show you where buffers are being allocated (LV 7.1).
    If you post a zip or llb of you code I am sure someone will have more to add.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I Append the same (altered) web page to the same Acrobat 9 Pro PDF file more than once

    The Acrobat 9 Pro utility in IE 8 of the Windows 7 Pro OS has a selection to "Append to Existing PDF," however it only allows appending the same web page one time only.  if the majoriety of the page data content is changed by selecting list item at the top of the page, I need to (re-)add the page with new content to the same (selected) PDF file, however the utilitiy does not allow this due to its maintaining a special index of each page base on the page URL or name.  Can the this index or the page itself be changed whenever the page is altered to make Acrobat think it is a new page? 

    I don't use IE, but I would suspect you can clear the cache or such to reset this option. You could also just open the web site directly in Acrobat and play the game there.

  • How do I create a multi-session in Mac OS 10.9.2 that can be 'appended' on a Windows machine?

    I need to be able to burn a CD with some files but leave the CD open so that someone else can add some files.  Although googling helped provide me some info on how to go about this once I need to burn the CD, but I am not sure that this CD will be able to be appended by someone using a Windows PC.  This is going to be a necessity.  Does anyone know about this or has had any luck doing this?
    Thanks in Advance

    I don't have a plain CD, but I tried a CD-RW and the ability to leave it appendable was not available. I'm not sure if that is related to CD-RW or if the feature was dropped in Mavericks.
    Check the More Like This links on the right.
    The process previously was to create an image of the folder that held the things you wanted to burn. Then, in Disk Utility, burn the image to disk and check the box to leave it appendable. This was only available for CDs, not DVDs.
    You might try some other burning software.

  • How can I append excel file rather than replace it?

    Hi,
    I have the attached VI set to write data to Excel, One case structure sends the data to cell B6, the other sends the data to cell B7. The problem is, the data is deleted from one cell when new data is added to another.
    I think I want to be able to append the data without deleting other cells. Any ideas?
    Thank you
    Todd
    Attachments:
    Flow meter write to Excel question.vi ‏180 KB

    Toddzilla,
    There are a couple different ways to append to excel files.  A couple links that might get you going are:
    Can I Add New Data to an Existing Excel File Without Erasing Old Data?
    Append Data to an Excel Document Every Iteration Using Report Generation Toolkit
    Are you trying to write over cells B6 or B7, or are you trying to append within the cell itself?  
    Hopefully this can get you on the right track.  When I append to files I tend to insert rows or append to the end of the file.
    Scott A
    SSP Product Manager
    National Instruments

  • How can I append to an array of defined length and have the first value added be the first value out.

    I want to build/append to an array. Let's say the length is defined at 10 elements. When the 11th element comes in I want the first element to be kicked out so that the array always has the most recent 10 elements in it in order. the arrays should look like this:
    {0,1,2,3,4,5,6,7,8,9}
    {1,2,3,4,5,6,7,8,9,10}
    {2,3,4,5,6,7,8,9,10,11}
    etc.
    Any help is greatly appreciated. Thanks 
    Solved!
    Go to Solution.

    Here's a revised VI, except I'm using LV8.5 and the lowest I can save down to is 8 so perhaps someone will be kind enough to convert this?
    Attached an image too
    Message Edited by Sima on 01-13-2009 06:14 PM
    Attachments:
    rotatearray[1].vi ‏14 KB
    rotatearray[1].JPG ‏66 KB

  • Can you append a link to a form with a query string to popular a form field?

    I'm trying to do this with Form Central but having no luck getting an answer. Is Acrobat Pro the answer?
    Thanks for your help
    Wayne

    Hi Irosenth
    That looks a great solution. However, I'm a newbie here and can't see that Adobe Pro gives an option to save a form as a .fdf or .xfdf.
    BTW the headline should say POPULATE not popular (whatever that is).
    What I would like to do is send an email to every recipient with a link to a form appended with a query string that automatically completes the ID field. At this point I only have Adobe Pro and FormCentral. Should I be looking elsewhere. (I did try to phone Adobe UK yesterday but was on hold for 1hr 4mins before I had to continue with the rest of my life).
    Thanks for your help & time.
    Wayne

  • Can I append date to the file name using Bursting

    Hi All,
    I know that we can append date to the file using %y, %m and %d for
    Email
    FTP
    WEBDAV
    But is there any way of appending the date to the file name if I am bursting my file to a shared location.
    I tried that %y, %m and %d but that doesn't work for bursting.
    Please reply
    Thanks,
    Ronny

    If this requirment is for EBS, please refer the following blog
    http://blogs.oracle.com/BIDeveloper/2010/08/xdoburstrpt_passing_parameters.html
    For standalone see the following delivery sql query as example.
    select
    d.department_name KEY,
    'Standard' TEMPLATE,
    'RTF' TEMPLATE_FORMAT,
    'en-US' LOCALE,
    'PDF' OUTPUT_FORMAT,
    'FILE' DEL_CHANNEL,
    'C:\Temp' PARAMETER1,
    d.department_name||'_'||to_char(sysdate,'mmddyyyy')|| '.pdf' PARAMETER2
    from
    departments d
    Thanks
    Ashish

Maybe you are looking for