Inserting text from one JTextpane to another

How do i insert text from one jTextpane to another with the attributes i used in the first. Please help.

i'm using a defaultstyleddocument. Also.....if u know
how i can transfer this data through a
DataOutputStream to another computer.Hi again,
DefaultstyledDocument uses a tree-structure with classes in it, that implements the Element-Interface to hold the styles. It is very easy to get the plain text, but what you need to transfer a part of text from one JTextPane with DefaultStyledDocument in it to another with the same document-style in it, is a sequence of (string, AttributSet) - pairs, so you are able to insert them in the destination document by the insertString(...)-method.
It is easy to get the Element by postion from the document and retrieve the Attributset from it that it uses in that position. I guess, an approach would be, to do the following:
get the Attributset at the start of the text = AttributSet of the pair
scan the document until the set changes
extract the string from start to the position right before the set changes = string of the pair
store the (String,AttributSet)-pair in a Vector
do this in the same way, but this time the "start" will be the position of the start of the new Attributset that causes the end of the scan above.
When this is done for the hole text, that is to be transferred, you have a Vector with the String-AttributSet-pairs that you can use to insert them in the other JTextPane by calling the
insertString(...)-method with this values.
Tell me, what you are thinking about that - I don't know another method for this and had to create a solution on the fly for you, so that is perhaps not the best way to do it.
greetings Marsian

Similar Messages

  • Copying text from one jtextpane to another

    Hi,
    I've two jtextpanes in my application. The first jtextpane holds styled text including icons. When i press the copy button i want it to be copied and appended to the text in the second jtextpane. how can i do this? :(...desperately looking for a solution...Thank you in advance...
    Edited by: THE_MACHINE on Jun 9, 2008 4:46 AM

    Maybe this can be of some use...
    try {
                jTextPane2.getStyledDocument().insertString(jTextPane2.getStyledDocument().getLength() - 1, jTextPane1.getText(), /*Your attribute set*/);
            } catch (BadLocationException ex) {
            }

  • Inserting data from one table into another table using PL/SQL

    HI,
    I am trying to insert values from one table into another using PL procedure, the values I want to retrieve from the table riverside1 are charac_id and charac_type and insert these values into another table called riverside2 , the stored procedure zorgs_gorfs(x,y) accepts two parameters which are 2 charac_id's of d characters in riverside1 then using insert statements inserts these characters from riverside1 into riverside2.
    CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
         BEGIN
              INSERT INTO riverside2
                   (charac_id)
              VALUES
                   (x);
    INSERT INTO riverside2
                   (charac_id)
              VALUES
                   (y);
          END zorgs_gorfs;
    /This works but the problem im having is that when I also try to insert the charac_type as well as the charac_id it doesnt work below is the code:
    CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
         BEGIN
              INSERT INTO riverside2
                   (charac_id,charac_tye)
              VALUES
                   (Select
                        charac_id,
                        charc_type
                   FROM
                        riverside1
                   WHERE
                        charac_id = x);
          END zorgs_gorfs;
    /can someone kindly sort me out

    modify this sql
    INSERT INTO riverside2
                   (charac_id,charac_tye)
              VALUES
                   (Select
                        charac_id,
                        charc_type
                   FROM
                        riverside1
                   WHERE
                        charac_id = x);as
    INSERT INTO riverside2
                   (charac_id,charac_tye)
              VALUES
                   (Select
                        charac_id,
                        charc_type
                   FROM
                        riverside1
                   WHERE
                        charac_id in ( x,y));But my suggestion would be consider revising your approach. It does not look that good.
    Thanks,
    karthick.

  • How can I copy text from one card to another while creating cards using Iphoto?

    I created two cards with different pictures using Iphoto on Macnotebook. 
    I want to use the same text message.
    How can I copy text from one card to another?

    select the text and copy (edit menu ==> copy) tehn gpo to the next card and paste
    LN

  • How do I copy text from one layer to  another?

    I have Googled this but not a single answer seems to work.
    I am using Photoshop CS4 on OS X 10.6.7.
    OK, so  I  have a layer that  has some text in it.  I would like to  be able to  simply copy that  text  from one layer  to  another, but this seems to  be impossible as the Edit Paste menu item is grayed out after I have copied it in to the clipboard.  I can paste it into  the SAME layer, but not into another layer.
    This is how I am trying to  do  this.
    In the layer  with the text, click on the "T" icon to  the left.
    Click on the text, in the layer that I  want to  copy. 
    I select the text (either  by  clicking and dragging or pressing Command-A).
    Next I press Command-C.
    Then I  click on the layer In the Layer Panel) where I want to  paste the text.
    Pressing Command-V is impossible because the Edit-Paste menu option is grayed out!!!!
    WHY??????
    Perhaps more importantly, HOW do I copy text  from one layer to  another?

    First thing you can simply right click on the Text Layer and choose Duplicate Layer.  But that will create a new Text Lay
    er identical to the one you have.
    To answer your question in your case....  Create the Text Layer.   Make a New Layer.  Or have the layer you want to paste into visible.
    Highlight the text layer in the Layer Palette and Ctrl+Click (Win) Cmd+Click(Mac) so that you see marching ants walking around your text.
    Edit>Copy.
    Then highlight your Layer you want to paste into and hit Edit>Paste or Cmd+V / Ctrl+V.

  • Move text from one artboard to another

    Hi I have 3 artboards open and am trying to move text from one artboard to another, each piece of text is on a different layer, but when I use the selection tool and just drag it across to the next artboard, nothing shows up.  How do I move text from one artboard to another?  Thanks

    Dont worry I now have it sussed.  I just needed to move the layers up in the stacking order.

  • Can I Copy and Paste text from one Contact to Another on iPhone 3G?

    Can I Copy and Paste text from one Contact to Another on iPhone 3G?
    Or even better while the iPhone is connected to my PC can I view the address book on the iPhone and make changes using my PC keyboard?
    I had a challenge importing from my outlook as it created dual entries for people I had with multiple email addresses or telephone numbers so I need to copy and paste contact info from one to antoher.
    Can anyone help?

    MCWEB wrote:
    Can I Copy and Paste text from one Contact to Another on iPhone 3G?
    You will be able to do copy & paste when 3.0 comes out this summer.
    Or even better while the iPhone is connected to my PC can I view the address book on the iPhone and make changes using my PC keyboard?
    No. You would make changes to the address book on your PC and then sync via iTunes.

  • Can Pages copy text from one page to another automatically?

    Can Pages automatically copy text from one page to another?
    For example recurring text in a document e.g. addressee details or a date (not today's date).
    I want to type the topic title of one letter and have it automatically filled into the correct field in the next page which will be a letter to a different recipient.
    The letter text will be different for each recipient so mail merge probably won't work.
    Thanks
    Andy

    Thanks that worked great!!!(for the first line)
    Now why wont it populate more than the one other text field?
    F.Lic.Table1.Row1.agt_ssn_lic.rawValue = xfa.event.newText;
    F.PAGE3.agt_ssn_1.rawValue = xfa.event.newText;
    F.PAGE4.agt_ssn_2.rawValue = xfa.event.newText;

  • I have never used PS, and I am trying to edit a brochure created by someone else.  I need to move text from one column to another

    I have never used PhotoShop and do not have time at the present. Please help me to move a section of text from one column to another in a brochure.

    Here are 3 options for future reference:
    1. With the setup you've described, apply a Match Move behavior to  the text and make the rectangle the source. Change the Transform parameter to Mimic source.  This way you can still adjust the text postion as needed, but the rectangle will drive the animation.
    2. Use a group to do the animation.  Put both your rectangle and text in the same group and animate the group's postion.
    3. Use the Link behavior.
    Each of these has it's advantages depending on what you need.

  • Copy Text from one quote to another

    Hi
    I need to copy text/notes related to one quotation to another.. I tried FM SAVE_TEXT and CRM_TEXT_MAINTAIN_OW but neither of it worked...
    Can anyone help me with this ?

    Hi Ashwineee,
    U can copy text from one quote to another by customizing also
    Just Check the settings of your text type in the text determination procedure.
    Select ur  text type and click on details u will find the text id description sequence and
    Transfer  field u have various options  u select the option "B" for ur text type .
    U can take reference of the  Standard Text determination Procedure "ORDER001"  for doing the same
    for your text determination Procedure
    Menu Path--
    Crm-Basic Functions- Text Management-Define Text Determination Procedure - select the Object --
    example for CRM_ORDERH and click on Procedure and select ur text determination procedure --     
    Select  Definition of Procedure that gives u details of  your   text type  and  its  options
    Hope it will Resolve ur problem
    Regards
    Pavan.A

  • How can I copy/paste text from one page to another?

    I feel like I am taking crazy pills... is there really no way to copy a text box (or group) from one page to another while creating books in Aperture 3?  Lets say I have my entire book laid out and I want to add one paragraph at the end on one page which will push text and photos down a half page or so... in most programs for the last decade or so they added really cool functionality... cut/paste...  It seems like the apple developers are aware of it because they are in the context menus but they don't work on text, only photo boxes.  Additionally, you can copy/paste text but it erases all formatting.
    Seriously, am I missing something?  I have trouble believing that they can't include this function.
    Anyone else have this issue?

    Update... it seems to only happen with text boxes which I create.  So when I try an existing theme I can cut/copy/paste just fine, but in that same theme if you edit the layout and add a new text box, I can't copy paste it anywhere... the options are in the menu but nothing happens.
    Thoughts? Solutions?
    I am running 3.4.3 on a MacBook Pro OS X 10.8.3

  • Edit Text from one screen to another screen

    Hi Experts,
           Here I am having two doubts in doing functionality on SMP 2.3,The below mentioned are the doubts,
                       1. In SMP 2.3 Version,When i am doing Hybrid App Designer in that  Edit Text functionality to pass the values from one screen to another screen,we want to type any text or digits in edit text keypad options is not opening in that field.If any one knows to handle that issue please let me know experts.
                       2.  In SMP 2.3 Version,When i am doing Hybrid App Designer we are taking some labels or buttons or edit box etc....,first time i am generating the hybrid app it is displaying in the mobile device what ever i give in that screen.Afterwards when i am updating second time in that screen with extra functionality labels or buttons or edit box etc...,and generating hybrid app,these time it is not displaying in mobile device which i gave not updating.If any one knows to handle that issue please let me know experts.
         For these both isssues if anybody gets solutions to handle these data please let me know and if links are there please provide it .
    Thanks & Regards,
      Lokesh Reddy G,
      9700414490.

    Hi Lokesh,
    Regarding your queries:
    1. What kind of device/simulator and OS you are testing your app? What is its version?
    Can you share the snapshots as well?
    2. What extra functionality you have added 2nd time? When you generating hybrid app 2nd time is it uploading in HWC container successfully?
    Meanwhile you can check this blog
    A workflow Application to Release A Purchase Order...
    Rgrds,
    Jitendra

  • Transfering text from one class to another

    Hi, I'm having a lot of trouble with getting the text from a textArea in a frame to transfer from one class to another.
    I could really use any help given.
    Thanks
    Here's where the text should come from
    import javax.swing.*;
    import BreezySwing.*;
    import java.util.*;
    public class UserFrame extends GBFrame {
    //String Design = null;
    private
       JTextArea InputArea = addTextArea
       ("...",1,1,1,1);
       JButton drawButton = addButton
       ("Draw" ,3,1,1,1);
    //  UserPanel dPanel = new UserPanel();
       GraphicsInputPanel dPanel = new GraphicsInputPanel();
       GBPanel panel = addPanel(dPanel, 1, 2, 1, 1);
       public void buttonClicked (JButton buttonObj){
          GraphicsInputPanel.setdesign(InputArea.getText());
    // rbPanel setDesign(graphicCodeArea.getText());
    public static void main(String[] args) {
    UserFrame tpo = new UserFrame();
    tpo.setSize(400, 300);
    tpo.setVisible(true);
    and here's where it should be going
    import BreezySwing.*;
    import java.awt.*;
    import java.util.*;
    public class GraphicsInputPanel extends GBPanel{
       String design;
       public void setdesign (String d){
          design = d;
       public void paintComponent (Graphics g){
          super.paintComponent(g);
          StringTokenizer lines = new StringTokenizer(design, "\n");
          while (lines.hasMoreTokens()){
             String line = lines.nextToken();
             if (design.equals ("Blue")){
                g.setColor(Color.blue);      
             }else if (design.equals("Green")){
                g.setColor(Color.green);
             g.fillRect(0,0,100,100);
         public void setDesign(String d){
          design = d;
          repaint();
    }

    Hello Saqib,
    The requirement to transfer asset with value date in the past year contradict the objective of audit trail established in the system although it is technically possible to do. Perhaps you should convince your client to adopt the standard approach, i.e. value date as at the date of asset transfer.
    Kind regards,
    John Chin

  • Loading text from one app to another

    If we are using text members and we want to transfer comments from one app to another.
    our steps are as follows.
    1) Export indicators in Essbase
    2) LCM text members out of one app to import into the other.
    3) load indicators in new app
    4) load LCM file to new app.
    The wrinkle is the following
    App 2 already has the exact same member for text and there is already text in separate spots (no overlap - think 2 different versions). But what about the number system when we bring it back in.
    Has anyone done this where you have to reallign the indicators in the relational database and essbase so that nothing gets crushed?
    We are thinking of editing the files and create new numbers. Will that work?
    This is version 11.1.2.2

    Hi,
    Mode of updation is delta.
    ZCUBE_2 already contains data from Aug. to March
    My problem is m not able to move March onwards data.
    Till today my delta was working fine.But i had to delete April data. Now i want to reaload it.
    Before deleting i tried to load 10 daya data all together, it reloaded successfully. Now i have to reload 48 days data, its not loading.
    I also to restict period in filter option, then also no data availabe is coming.

  • Create Trigger to insert records from one table to another

    I created the below trigger to move data from one table to another after records have been inserted from another table to that table. What I need done is that each time records have been inserted into TEST_TBL, one of these actions codes should be implimented: U-update, N-insert, D-delete and inserted into TEST_TBL1. But each time I run the script, I get bunch of errors. Please see the script below: - Your help will be appreciated.
    create or replace
    trigger POWER_tr
    after update or insert or delete ON test_tbl
    for each row
    begin
    if updating then
    insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'U', sysdate);
    ELSif INSERTING then
    insert insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'N', sysdate);
    ELSIF deleting then
    insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'D', sysdate);
    END IF;
    END POWER_tr;
    Thank you,
    Albert Zaza
    Edited by: azaza on Mar 1, 2009 4:14 PM

    Hello
    At the end of trigger show errors / and post what errors are you getting exactly?
    Here is a simple example for your reference, this will save old values in history table; you can replace it with new values if that's what do you want.
    CREATE OR REPLACE TRIGGER TRG_DU
       AFTER DELETE OR UPDATE
       ON EMPLOYEE    REFERENCING NEW AS New OLD AS Old
       FOR EACH ROW
    DECLARE
    BEGIN
       IF UPDATING
       THEN
          INSERT INTO employee_hist
            VALUES   ('UPDATE',
                      :OLD.empid,
                      :OLD.name,
                      :OLD.deptid);
       ELSIF DELETING
       THEN
          INSERT INTO employee_hist
            VALUES   ('UPDATE',
                      :OLD.empid,
                      :OLD.name,
                      :OLD.deptid);
       END IF;
    EXCEPTION
       WHEN OTHERS
       THEN
          -- Consider logging the error and then re-raise
          RAISE;
    END TRG_DU;
    /Regards
    Edited by: OrionNet on Mar 1, 2009 7:27 PM

Maybe you are looking for