JTextPane first line read only

Hi all!
I'm a beginner in java programming, that said im trying to make a simple text editor (who isn't?), it will be a part of another larger application, nevertheless this editor is a main component, just need some simple editing tips.
I want to use a JTextPane for the editable surface, this is working fairly well but i am not able access other lines in the editor except from the first one. Meaning that when containing a large piece of text, my JTextPane is only able to edit the first line: For instance the caret will only show it self on the first line, I can write new letters, but only on the first line and i can erase them and so on. What am I missing? Have checked around many places for solutions
To sum it up; I want to edit every line in my JTextPane instead of just the first one :)

Ok! thanks a lot for the good advice, ant help is most appreciated. :-)
Here is a piece of code that demonstrates my problem. Hope it brings insight! Try to write a line of text, then press enter to go to the next line, most probably you will find yourself unable to edit this line.
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
public class Test implements Runnable
     public static void main(String[] args)
          SwingUtilities.invokeLater(new Test());
     public void run()
          JPanel cP = new JPanel();
          JTextPane tP = new JTextPane();
JScrollPane sP = new JScrollPane( tP );
tP.setPreferredSize(new Dimension( 400 , 400 ) );
          sP.setPreferredSize(new Dimension( 300 , 300 ) );
          tP.setEditable(true);
          cP.add(sP);
          JFrame f = new JFrame();
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          f.setContentPane( cP );
          f.setLocationRelativeTo( null );
          f.setVisible( true );
}

Similar Messages

  • Only about 2/3 of the column show. Also, paragraphs on sidebars, such as the Youtube subtitle sentences are cut so after the first line I only see the top of the second line.

    Only about 2/3 of the column show. Also, paragraphs on sidebars, such as the Youtube subtitle sentences are cut so after the first line I only see the top of the second line.

    If you have increased the minimum font size then try the default setting "none" as a high value can cause issues like you described.
    * Firefox > Preferences > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    * Firefox > Preferences > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above"
    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • Validation for first line item ( table )

    Dear Friends,
    i have table with multiple line items, i want to validate first line item only, if first line item is initial, it should throw an error message, could any one pls help me with an example
    Thanks
    Vijaya
    Col1
    Col2
    Col3

    Hi Vijaya,
    Method get_static_attributes_table of interface if_wd_context_node will return a table of context elements. You can then either read the first row of that table or loop through it to validate the table's data and issue messages as needed. For example...
    data lo_nd_ctx_node type ref to if_wd_context_node.
    data lt_attributes_table type wd_this->elements_ctx_node.
    lo_nd_ctx_node = wd_context->get_child_node( name = wd_this->wdctx_ctx_node ).
    lo_nd_ctx_node->get_static_attributes_table( importing table = lt_attributes_table ).
    If the row to be validated happens to be the table's lead selection, you can fetch attributes of the lead selection row directly, and again validate and issue messages as needed...
    data lo_nd_ctx_node type ref to if_wd_context_node.
    data lo_el_ctx_element type ref to if_wd_context_element.
    data ls_attributes type wd_this->element_ctx_node.
    lo_nd_ctx_node = wd_context->get_child_node( name = wd_this->wdctx_ctx_node ).
    lo_el_ctx_element = lo_nd_ctx_node->get_element( ).
    lo_el_ctx_element->get_static_attributes( importing static_attributes = ls_attributes ).
    Both of these code patterns to read context data are available through the Web Dynpro Code Wizard.
    Cheers,
    Amy

  • Read only tables

    I am trying to write protect a Table so that it can only be viewed by others but not write (modified) the data in the table.
    How can I create and modify a table in order for it to be only viewable.
    Thanks

    Should be no problem, as long as your GIS application does not log in to the database as the owner of the table with the SDO_GEOMETRY.
    The following example (laboriously) demonstrates this from creating two users through proving the second can only get the data owned by the first in read/only mode.
    I've given the second the priv of creating a private synonym to avoid constantly having to reference the owner's name.
    It's all done in sqlplus, however, the italicized comments are not in the sqlplus source.
    pop2@fuzzy:~> sqlplus system/password
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Apr 24 08:21:27 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Create the sdo_owner and the sdo user.
    Give the first permission to create tables, the second permission to create synonyms
    but (in this case) not tables.
    SQL> create user sdo_owner identified by sdo
      2  default tablespace users temporary tablespace temp
      3  quota unlimited on users
      4  account unlock;
    User created.
    SQL> create user sdo_user identified by sdo
      2  default tablespace users temporary tablespace temp
      3  quota unlimited on users
      4  account unlock;
    User created.
    SQL> grant connect, create table to sdo_owner;
    Grant succeeded.
    SQL> grant connect, create synonym to sdo_user;
    Grant succeeded.
    Connect as the owner, create and data fill the table.
    Give the user the permission to select only
    SQL> connect sdo_owner/sdo
    Connected.
    SQL> create table my_layer (
      2    layer_item varchar2(20),
      3    geom sdo_geometry
      4  );
    Table created.
    SQL> insert into my_layer
      2  values ( 'Test',
      3     SDO_GEOMETRY( 2003, 8203, sdo_point_type ( 15, 45, null ), null, null )
      4  );
    1 row created.
    SQL> grant select on my_layer to sdo_user;
    Grant succeeded.
    Now connect as the user, verify we can get information.
    Create a synonym to save typing.
    Check that it works, and finally see whether this is truly read-only.
    SQL> connect sdo_user/sdo
    Connected.
    SQL> select * from sdo_owner.my_layer;
    LAYER_ITEM
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    Test
    SDO_GEOMETRY(2003, 8203, SDO_POINT_TYPE(15, 45, NULL), NULL, NULL)
    SQL> create synonym my_layer for sdo_owner.my_layer
      2  ;
    Synonym created.
    SQL> select * from my_layer;
    LAYER_ITEM
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    Test
    SDO_GEOMETRY(2003, 8203, SDO_POINT_TYPE(15, 45, NULL), NULL, NULL)
    SQL> insert into my_layer values ( 'Test Insert',
      2  SDO_GEOMETRY( 2003, 8203, sdo_point_type ( 15, 45, null ), null, null )
      3  );
    insert into my_layer values ( 'Test Insert',
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL> update my_layer set layer_item='Updated';
    update my_layer set layer_item='Updated'
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL> delete from my_layer;
    delete from my_layer
    ERROR at line 1:
    ORA-01031: insufficient privilegesHopefully others will be able to use the example as well, as this works the same for non-spatial stuff.
    HTH
    /Hans

  • Renaming PDFs by first line in pdftotext output

    Dear Arch community,
    I would like to rename PDFs with cryptic names into their titles, which are in the first line of the files
    pdftotext sw-b-13-0094.pdf
    head -n 1 sw-b-13-0094.txt > title
    mv sw-b-13-0094.pdf $(title)
    But I can't figure out how to do this exactly.

    You're just about there.  The problem is your second line creates a file called title, then the third line tries to execute that file to get the new name.  You could add "cat" to the third line as follows.  This should work, but it would not be my recommended approach:
    pdftotext sw-b-13-0094.pdf
    head -n 1 sw-b-13-0094.txt > title
    mv sw-b-13-0094.pdf $(cat title)
    Instead, it'd be much cleaner to just use a shell variable:
    pdftotext sw-b-13-0094.pdf
    title=$(head -n 1 sw-b-13-0094.txt)
    mv sw-b-13-0094.pdf $title
    But this can be further improved by not littering all these text files all over - instead use a pipeline rather than actually creating a txt file:
    mv sw-b-13-0094.pdf "$(pdftotext sw-b-13-0094.pdf | head -n 1).pdf"
    Now, hopefully it should be clear how you can even replace the current pdf filename (sw-b-13...) with a parameter ($1) for a script or shell function - or have this loop through all pdf files in a directory.  If you want help with that too, let us know.
    EDIT: be careful to ensure that the first line of pdftotext actually has something meaningful.  If all the pdfs were created in the same way, this might be known.  But it is common for some whitespace or formatting character to be the first line.

  • Arraylist only reading first line of file

    I am reading a text file using an arraylist. my file has a single value on each line e.g.
    2
    3
    4
    5
    however this method is only reading only the first line of each file. is it because of this statement:
    String s1[] = number.split("\\s");
    I would like to change the method so its not expecting numbers in a single line.. but reads each line and adds it to the collection... how can I do that?
    here is getData method that gets the file and processes it.
         public static List<Integer> getData(String Filename) {
              List<Integer> array1 = null;
              // BufferedReader for file reverse.txt
              try {
                   array1 = new ArrayList<Integer>();
                   BufferedReader bf = new BufferedReader(new FileReader(Filename));
                   String number = bf.readLine();
                   String s1[] = number.split("\\s");
                   for (int i = 0; i < s1.length; i++)
                        array1.add(Integer.parseInt(s1));
              } catch (Exception e) {
                   e.printStackTrace();
              return array1;

    Faissal wrote:
    while(bf .ready()){
    readline() will return null if the end of the stream has been reached. ([http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html]). This condition can be used to determine when to stop reading thereby ensuring that all lines have been read.
    EDIT:
    Here's a code snippet from [Java Developers Almanac|http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html]: notice how they close() the stream when they're finished with it.

  • "read from measurement file" reads only first line of data

    Hello,
    I have a problem when trying to read a .lvm file through "Read from Measurements file" with the following block diagram
    Problem: it reads only the first line of data from what I can see in the probe window,.
    A part of the lvm file for reference.
    I haven't used Labview in a long long time, I'm trying to figure out what I am doing wrong.
    Thanks

    Sorry meant to attach the lvm. Here it is. (Actually I had to put it in .txt because the forum wont let me upload a lvm file)
    I unfortunately cannot share the full vi that record the data as I am not its owner/creator. I'll try to give as much info as I can with the relevant pictures attached, I hope it allows us to at least have an hint of where the problem might be.
    (this is in a while loop)
    In the stacked sequence, the other pannels are similar to the one shown here: value read fron a variable, converted to dynamic and a signal attribute is set. The "start recording" control operation is "switch when pressed".
    Here are the properties of the set signal attributes
    And here are the properties of the "write to measurement file"
    Attachments:
    NoTarget_full circle__Rx_-10-SAMPLE.txt ‏60 KB

  • Powershell read CSV file line by line and only first header

    I have a CSV file, which reads like this:
    read, book
    read1, book1
    read2, book2
    I want to read only the first value, before comma one line at time,
    meaning first time it will be
    read
    read1
    read2
    no headers and i want to pass that value to a variable for a if condition.
    I have script it read line by line but it reads both values before coma and after line by line, so instead of having three values i'm ending with 6 values.
    $file = Import-CSV c:\script\server.csv
    $file | ForEach-Object {
            foreach ($property in $_.PSObject.Properties) 
    $property.Name
    $property.Value
    #replace = $property.Value

    If you can work with headers then do so as it will make your life easier.
    with a csv file called server.csv like this:
    headername1, headername2
    read, book
    read1, book1,
    read2, book2
    and this bit of code 
    $file = Import-CSV c:\script\server.csv
    #output to host, file or directly pipe the command above.
    foreach($cell in $file.headername1){ if($cell -eq $something){ }}
    will evaluate the content of each cell to $something.
    This is because Powershell will grab the first row and claim that as a header name.
    So whatever you put in cell A1 in excell will end up as name of the first collumn and its corresponding property (e.g. $file.A1 oor $file.headername1 if you will).

  • Generally when creating a Word file from either a Mac or Win7 pc and opening it on two different machines (either one first) it always prompts that the file is open and will be opened as read only. However opening a CSS file does not prompt that it is alr

    Generally when creating a Word file from either a Mac or Win7 pc and opening it on two different machines (either one first) it always prompts that the file is open and will be opened as read only.
    However opening a CSS file does not prompt that it is already open on or from any machine which is causing code edits to be lost.
    What we found from out testing:
    - The file can be saved from one user to the server and WILL NOT PROMPT on other machines until the saving machine has the Dreamweaver program closed completely
    - The file can be closed and  Dreamweaver minimised to the launch bar but it still will not register on other machines that it has been changed.
    - Also, until the  Dreamweaver program is closed on the machines, it will continue to open it's saved version of the file. 
    Example Scenario:
    - User 1 opens test.css (which is 2000 lines) and adds some code to the end of the file to bring it up to 2500 lines
    - Meanwhile User 2 opens test.css as well (opens as 2000 lines as User 1’s edits have not yet been saved) and adds in code to bring it to 2300 lines
    - User 1 saves his file and closes it - but  Dreamweaver is still open.
    - User 2 also saves his file and leaves  Dreamweaver  open.
    - The server will report the size and last edit of the file the same as User 2 as he was the last person to save it (and if you open from the Win7 Machine it will show as User 2’s 2300 line version)
    - If User 1 then open's the file again (from either the 'recent' in Dreamweaver OR clicking on the file directly in Finder...which version opens.... The version that User 1 saved! Not the true version on the server, but the version that User 1 edited and saved with 2500 lines in it.
    - Same for User 2, he will open 'his' version with 2300 lines in.
    Other information:
    - Files are opened directly from the server
    - Sometimes the users will save incrementally and re-open
    - Most of the time users will save incrementally and keep the files open
    - The users will never not save incrementally and just save when closing the file once finished
    - The users are usually working on the files all day
    - It is always the bottom lines of code that are lost. It could be a case of the two versions being mixed up and cutting off the newly added lines based on the line count (possibly).
    It is as if Dreamweaver is holding a cache of the version locally and then only properly looking back to the server when it has been completely closed. It is very difficult to see how the server is causing such an impact on these files, there are very few logs which are giving any indication to the root cause of the problems.
    Anyone know if this is a known issue?
    Is there a way that there can be a featured implemented on the server that doesn't allow another user to open a file if it is already open on another machine?
    Thanks

    Your server file handling has nothing, and really nothing to do with Adobe software. If files don't get locked for (over-)writing and/or lose connection to the program opening them, then your server is misconfigured. It's as plain and simple and that. Anything from "known file types"/ file associations not being set correctly, MIME types being botched, crooked user privileges and file permissions, missing Mac server extensions, delayed file writing on the server, generic network timeout issues and what have you. Either way, you have written a longwinded post with no real value since you haven't bothered to provide any proper technical info, most notably about the alleged server. Either way, the only way you can "fix" it is by straightening out your server and network configuration, not some magic switch in Adobe's software.
    Mylenium

  • Read only account line item appears writable in the webform

    Hi All,
    We are using Hyperion Planning 11.1.1.2.We have a line item called "Salary" under account which is set to read only.Its parent "Compensation" has the security set as IDesc(writable).
    The line item Salary is used in 2 forms.In one form it appears as readonly and in the other it appears as writable.Both the forms are identical except for the change in member in custom dimension for which security is not applied.
    Ideally this line item has to appear as readonly.
    Can anybody throw some light on this issue?
    Thanks in advance,
    Malini

    Hi,
    Can you just try this,edit the first form that works, do a save as and give it a name, change the custom dimension member. save. run. Is it the same?
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

  • Read ONLY a line in file

    Hello expert,
    I have a file which have lots of records, i want to read the first line only. how can i do this. I've tried GUI_UPLOAD. it retrieve all the file data but i dont want this, i want it to retrieve ONLY the first record.
    Any solution experts.

    Hi Hassim,
    you can delete other records once read fom file as below, you will remain with first record.
    DESCRIBE TABLE t_record LINES l_line.
    DELETE t_record FROM 2 TO l_line.
    Or
    Use FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' mention as below.
    Let us take if you have 4 colums and many rows and u want to read all 4 columns of first row, read like below.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                = l_file
        i_begin_col             = 1
        i_begin_row             = 1
        i_end_col               = 4
        i_end_row               = 1
      TABLES
        intern                  = t_record[]

  • File Sender adapter not reading the first line

    Hi,
    I have a scenario configured from file to jdbc adapter.
    However, I found a problem in my file sender adapter. My file adpater always not picking up the first line from my text even I have set the 'Document Offset' to 0.
    Any Ideas? Thanks.
    Regards,
    Pua

    Hi Latika Sethi,
    My complete input text file is as below, it contains only 2 testing records:-
    H1|DIZ1                          |A0016507    |10000020|09/2007
    H2|ABC0001
    D|P|0001|Gaji Pokok       |   1,000.09
    D|D|0002|Denda              |   1,000.00
    D|P|0003|Elaun               |   1,000.00
    H1|PUA1                        |A0016508    |10000021|09/2007
    H2|ABC0002
    D|P|0001|Gaji Pokok       |   2,744.09
    D|D|0002|Denda              |   2,000.00
    D|P|0003|Elaun               |   2,000.00
    After the message mapping, I found the pipeline existed in sxmb_moni as below:-
    <?xml version="1.0" encoding="utf-8"?>
    <ns:mt_rmp03B_filejdbc_sender xmlns:ns="urn:rmp03:pdrm:ips:jdbcjdbc">
    <PaySlip>
    ..<Header2>
    .... <IC>ABC0001</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>1,000.09</Jumlah>
    .. </Details>
    </PaySlip>
    <PaySlip>
    .. <Header1>
    .... <Nama>PUA1</Nama>
    .... <KWSP>A0016508</KWSP>
    .... <NoGaji>10000021</NoGaji>
    .... <Bulan>09/2007</Bulan>
    .. </Header1>
    .. <Header2>
    .... <IC>ABC0002</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>2,744.09</Jumlah>
    .. </Details>
    </Payslip>
    There are 2 payslips as for the top payslip node...Header1 tag is missing. It means that during the file sender step....the first line of my record which is :-
    "H1|DIZ1                          |A0016507    |10000020|09/2007"
    is not read into the xi pipeline. Basically this is the problem i faced.
    Has somebody facing the same problem before? Currently I have no choice but moved the First line of the text into Second line and left the first line of the text become null/ empty line. As such both records can be successfully read by the XI.
    However what I wondered is sometimes clients will do insert the records into the first line and this might made some data loss.
    Thanks...

  • PDF showing only first line of Table?

    Hi @,
    I am showing an input table to PDF using adobe Int Form and in the Adobe screen it is displaying only the first line of the table.
    I am using CE 7.1 SR5.
    Regards

    Hi,
    When the XML interface is generated for the context, for every node that has cardinality 0..n or 1..n, a node named DATA is generated in the XML.
    So if your Webdynpro context has foll structure...
    Node1 ... 1..1
      Node2 ... 0..n
        Attrib1
        Attrib2
    The corresponding XML would be
    Node1
      Node2
        DATA
          Attrib1
          Attrib2
    Regards,
    Reema.

  • Program to read only specific words in each Line in a text file

    Hi
    I have a question
    I need to write a program where the program must read only specific words in each line
    I will give you an example...
    PSAPPSRV.21201      1-42 13.35.54 238.360 Cur#1.HDEV RC=0 Dur=0.000 COM Stmt=SELECT VERSION FROM PSVERSION WHERE OBJECTTYPENAME = 'SYS'
    PSAPPSRV.21201      1-43 13.35.54 0.040 Cur#2.HDEV RC=0 Dur=0.000 COM Stmt=SELECT STYLESHEETNAME FROM PSOPTIONS
    These are two lines in my text file...now I need to read only the SQL statements present that is both SELECT statements.. Can you please suggest a method.......

    My first reaction to the question is why would you want such thing, but may be I am unknown :)
    Assuming you have the text as string, I mean
    String str = "PSAPPSRV.21201 1-42 13.35.54 238.360 Cur#1.HDEV RC=0 Dur=0.000 COM Stmt=SELECT VERSION FROM PSVERSION WHERE OBJECTTYPENAME = \'SYS\'";you can obtain the sql statement using substring method like
    String result = str.substring(str.indexOf("SELECT")); Again I assume there is no word SELECT preceding and the word SELECT is all caps.

Maybe you are looking for

  • IPhone 4 Photos Accelerometer not working

    I just received a new iPhone 4 and the Photos application appears to ignore the accelerometer and is always stuck in portrait mode. All other apps work fine, just Photos is not working. This is a new phone setup, not a restore from a previous phone.

  • My troubles with Drobo (2nd Gen.)

    Hey everyone. I wanted to put my experience here so that people could chip in and learn/share. For the past five months I had been having with my Drobo (2nd Gen with 2 FW800s and USB 2.0). It came bundled with 2x 1 TB WD drives. I set it up using Dro

  • FWSM Active/Standby in VSS mode

    hello, i do have two 6500 in VSS mode , and one FWSM module on each 6500, i want to configure these modules as Active/Standby, how do i start , should i  follow this (not in VSS mode): http://www.cisco.com/en/US/docs/security/fwsm/fwsm32/configuratio

  • Issue with mail, it freezes everytime I open it, the wheel spins.

    ONce opened mail freezes and the wheel spins. In the Window menu there are 12-15 message viewers, telling me that are open, but do not appear anywhere on the finder. It appears that it maybe a conflict of some sort, but I can not figure it out. No up

  • Can I block part of quantity of a material in a bin?

    Dears, I want to find a solution that blocking material partially in a storage bin in WM. Is there any standerd solution in WM? Please help! Thanks. Regards, David