Only one character in a JTextPane using a DefaultStyledDocument

Heya,
I'm developing a program to read and filter some big traces file and I'm having a little problem now.
I've done a small text program, with the class MyFile, MyDocument, FileViewer and Test, I try to load myDocument in a JTextPane but I only see the first character of the document. Maybe I nedd to implement more function in MyDocument class, I've also read some thing about the Element but I'm a little loose, I don't know which way to choose for my test.
Hope you could help me,
Thanks.

Here a part of my code FileViewer class
         * Set properties of the components
        mainWindowApplication.setTitle("Traces Restit Test");
        mainWindowApplication.setSize(640, 480);
        //tracesTextPane.setText("test");
        //tracesTextPane.setContentType("DefaultStyledDocument");
        tracesTextPane.setEditable(false);
        tracesTextPane.getCaret().setVisible(true);
        // Creation of the scrollable areas - ENTRAINE UN BUG ET NE FONCTIONNE PAS VRAIMENT
        //scrollTraces = new JScrollPane(tracesTextPane,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) ;
        loadFileButton.setText("Go test !");
        colorLineButton.setText("Color 1/2 !");
        clearButton.setText("Clear !");
        exitButton.setText("Quit");
        myDocument = GUI_myDocument;      
         * Style, red letter
        final Style styleRed = tracesTextPane.addStyle("Red", null);
        StyleConstants.setForeground(styleRed, Color.red);
        StyleConstants.setFontSize(styleRed, 14);
         * Odd line will be in red, pair line are keeped in black
        for (int lineNumber = 0; lineNumber < myDocument.myFile.getNumberOfLines();
                lineNumber++) {
            if ((lineNumber % 2) == 0) {
                // Get the line
                int offsetBeginLine = myDocument.getOffsetBeginLine(lineNumber);
                int offsetEndLine = myDocument.getOffsetEndLine(lineNumber);
                int lengthLine = myDocument.getLengthLine(offsetBeginLine,
                        offsetEndLine);
                // Odd line in red
                myDocument.setCharacterAttributes(offsetBeginLine, lengthLine,
                    tracesTextPane.getStyle("Red"), true);
        // TEST
        //myDocument.setCharacterAttributes(0, 5,tracesTextPane.getStyle("Red"), true);
         * Initialisation of the reading task progressBar
        taskProgressBar = new JProgressBar(0);
        taskProgressBar.setValue(0);
        taskProgressBar.setStringPainted(true);
         * Specify LayoutManagers to arrange components in the containers
        mainWindowApplication.getContentPane().setLayout(new BorderLayout());
        buttonPanel.setLayout(new FlowLayout());
        tracesPanel.setLayout(new BorderLayout());
         * Add components to containers, layout constraints
        buttonPanel.add(taskProgressBar);
        buttonPanel.add(loadFileButton);
        buttonPanel.add(colorLineButton);
        buttonPanel.add(clearButton);
        buttonPanel.add(exitButton);
        //tracesPanel.add(scrollTraces);
        tracesPanel.add(tracesTextPane);
        mainWindowApplication.getContentPane().add(tracesPanel, "Center");
        mainWindowApplication.getContentPane().add(buttonPanel, "South");

Similar Messages

  • How to get only one character

    my problem is the following:
    i want to get only ONE character from the input without pressing the "enter"-key. for example pressing ESC and doing something because it is ESC hit.
    thank you

    You can't. Either use a GUI or create a JNI DLL function that calls getch ().
    Kind regards,
      Levi

  • I have used only one laptop since I started using apple products, but itunes notified me that i have authorised 5 computers. how do i correct this

    I have used only one laptop since I started using apple products, but itunes notified me that i have authorised 5 computers. how do i correct this

    Deauthorize all, then authorize the active computer.

  • Insert only one character in a JTable cell

    Hi1
    Can anybody tell me how i can do in order to insert only one character in a JTable cell? For example, i'ld like that user inserts only
    a and not abcd in a JTable cell... can anyone halp me?
    Thanks

    Have you tried
    table.getColumn(0).setCellEditor(new DefaultCellEditor(new JFormattedTextField("[A-Z]")));
    I haven't tried it. You might look at some of these.
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2B%22new+defaultcelleditor%22+%2B%22new+jformattedtextfield%22&col=javaforums&x=39&y=17

  • How to remove only one row from the database using labview6.1

    using labview 6.1 I create a table with various rows and columns and store bulk of data's in them.,, what procedure should I follow to remove only one paticular row from the database? Help me out with an example please,,
    Thanking you in advance!

    Hi,
    If you have the database toolkit you can delete a row using just a SQL Query to "DB Tools Execute Query.VI"
    Example:
    DELETE FROM Table name Where SerialNum='Value' And Date='Value' And Time='Value'
    See also attached VI
    Best Regards
    Johan
    Attachments:
    Delete_a_row_in_a_database_table.vi ‏48 KB

  • Can I create action to Save As...  and change only one character of the original file name?

    I'm working on a group of  files(25-28) at a time. I have to save each one as a photoshop .raw file and change the first character of the file name. the rest of the file name must remain the same. I then close the original file with no changes. I tried to create an action for this. The only problem is that the next file overwrote the file I used to create the action.  Is it possible to creat an action to save as... and keep the file name of the new file but chage the first character to the same one used in the recording?

    Good day!
    I think what you are describing is not possible with Actions.
    Scripting would be an option, but more convenient might be simply saving the files with unchanged names and then edit the names of  the whole bunch in Bridge in one go (Tools > Batch Rename).
    Regards,
    Pfaffenbichler

  • HT204053 My iPhone will not let me download my books that I purchased on my iPad. Says something about only one apple ID can be used on that device every 90 days.

    Why can I not open my books on my iPhone.  

    Have you used another account on your phone for iTunes match, automatic downloads or re-downloading past purchases : http://support.apple.com/kb/HT4627 ? If you have then you will need to wait until the 90 days have completed before you can link it to another account - you could try copying the books from you iPad to your computer's iTunes via File > Transfer Purchases (File > Devices > Transfer Purchases on iTunes 11) and see if you can then sync them to your phone

  • When I have only one tab/window open, I used to be able to use Command-W to close it. All of a sudden, it won't let me do that. Any idea why that might be?

    I tried re-installing version 7.0.1 but that didn't help.

    about:config
    browser.tabs.closeWindowWithLastTab
    Set this to TRUE
    You're welcome! :)

  • HT4539 When having multiple user accounts on a mac can only one of you use the automatic downloads in iTunes?

    Why is it that in itunes on a mac, if you have multiple users, that only one apple id can be used for automatic downloads?

    See if this helps: iTunes: How to share music between different accounts on a single computer

  • Find and print illegal character in a string using regexp

    I have the following simple regexp that checks for illegal characters in a string:
    String regexp = ".*([\\[\\];]+|@).*"; // illegal: [ ] ; @
    String input = "Testing [ 123";
    System.out.println(Pattern.matches(regexp, input));How can I find and print the character that is invalid??
    I've tried using the Matcher class togheter with Pattern but cant get it to work. :(
    Like this:
    Pattern pattern = Pattern.compile(regexp);
    Matcher matcher = pattern.matcher(input);
    matcher.lookingAt();
    int matchedChar = matcher.end();
    if (matchedChar < input.length()) {
        String illegalCharFound = String.valueOf(input.charAt(matcher.end()));
        System.out.println(illegalCharFound);
    }What am I doing wrong?

    1. You call lookingAt(), but you don't check its return value, so you don't know if the regex actually matched.
    2. matcher.end() returns the index of the character following whatever was matched, assuming there was a match (if there wasn't, it will throw an exception). So either it will point to a legal character, or you'll get a StringIndexOutOfBoundsException because an illegal character was found at the end of the input. The start() method would be a better choice, but...
    3. Your regex can match multiple consecutive square brackets or semicolons (and why not put the at-sign in the character class, too?), but you're acting like it can only match one character. Even if there is only one character, group(1) is an easier way to extract it. Also, if there are more than one (non-consecutive) illegal characters, your regex will only find the last one. That's because the first dot-star initially gobbles up the whole input, then backtracks only as far as it has to to satisfy the rest of the regex. If your goal is to provide feedback to whoever supplied the input, it's going to be pretty confusing feedback. You should probably use the find() method in a loop to pick out all the illegal characters so you can report them properly.

  • How to change one character string to char

    hi all
    i got string but only one character
    i got 1,2,3,E
    since i got 'E' here..........
    i need to convert to it to character....
    but how to change it.... i only know String to integer using Integer.parseInt() method....
    but i don't know about char...................

    You should really check the API first:
    http://java.sun.com/j2se/1.4.2/docs/api/index.html
    Take a look at String.charAt(int index) method.
    /Kaj

  • Find files that match with given string, except one character in a fixed position

    Hi,
    I want to find files in a directory with a given string (ss-20140129-process-000*.sdx), where only one character will be mismatched, so have to use wildcard for that character. This means I am looking for filenames where everything needs to be matched except
    one character in position of "*". For the samples given below: 1st 3 files matched with the given string, but last 3 files have not matched, so first 3 files will be counted.
    ss-20140129-process-0001.sdx
    ss-20140129-process-0004.sdx
    ss-20140129-process-0009.sdx
    zx-20140129-process-0001.sdx
    bt-20140129-process-0002.sdx
    zx-20140129-process-0001.sdx
    I can use the command like (GCI -path $folder -filter ss-20140129-process-000?.sdx), BUT problem is i am building a string for the filter (code given below), where i DO NOT know how to use "?" within the string to make a character exception.
    Code:
    $datevalue = [datetime]::parseexact($trandate,"MMddyy",$null)
    $yyyymmdd = $datevalue.tostring('yyyyMMdd')
    $FileToCheck = ("ss-"+$yyyymmdd+"-process-000?.sdx")
    GCI -path $folder -filter $FileToCheck
    But it's definitely NOT working for syntax problem.
    Any help?

    I don't think it's a syntax issue in the filter.  This works fine for me:
    $yyyymmdd = '20140129'
    $FileToCheck = ("ss-"+$yyyymmdd+"-process-000?.sdx")
    Get-ChildItem -Path . -Filter $FileToCheck
    <#
    Output:
    Directory: C:\source\Temp\sdxtext
    Mode LastWriteTime Length Name
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0001.sdx
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0004.sdx
    -a--- 1/30/2014 10:16 AM 0 ss-20140129-process-0009.sdx
    #>
    You can try adding some debug output right before the call to Get-ChildItem. Check the values of $Folder and $FileToCheck, make sure they're correct. You can also fiddle with the values and call Get-ChildItem manually until it works, which would then tell you
    how the code needs to be changed.

  • I have on;y one audio port can i use it for input and output at the same time?

    i have the new macbook pro 13 in and i want to connect aguitar as input and output on an amp but i have only one audio port

    You can't use the jack as an input and output simultaneously. The solution is to look for a USB or Firewire interface to get your guitar sound into the computer.

  • All rows in a Set get updated when only one row changes

    I have a complex object, which contains a Set of child objects. If i modify one of the child objects and put the object back in the cache, coherence will issue a sql update for each of the child objects, even though only one changed.
    I'm using hibernate, and when i do this in straight hibernate, that doesn't happen, only one sql update gets issued for the row in question.
    I found this because i have a timestamp column that automatically updates when the row gets updated, but since all the child rows are updating, this timestamp gets updated as well which breaks the biz logic.
    Am i missing something? Clearly it's inefficient to issue updates on all the child rows when just one changes. Is there some way to avoid this?
    Using coherence 3.5.3.
    Thanks.

    This turned out to be an issue with POF serialization of a Date object. It was doing it incorrectly, it would get the day correct, but the HH:MM:SS would be set to the current time. Since the object had been changed, when i persisted the parent, all of the child rows would persist as well since their "modify_date" attribute had been changed. Eg, if the date in the DB was "2010-07-14 03:10:00" when i read the object in, the value would change to "2010-07-14 HH:MM:SS" where HH:MM:SS would be set to the current hours/mins/secs.
    I changed the code to use my own serialization of a Date object (just used the long) and things worked fine after that.
    Is this a known issue with pof serialization?

  • Configuring PPP options for only one VPN connection

    How do you configure PPP options for only one VPN connection that is using L2TP over IPSec? The built-in VPN client in 10.4.9 is failing authentication because it won't talk MSCHAP-V2 (this is the only authentication protocol I can use) with the server. I am able to establish a connection if I add the following to /etc/ppp/options:
    refuse-eap
    refuse-pap
    refuse-chap
    refuse-mschap
    require-mschap-v2
    However, these options will affect all PPP connections. The preference file that contains the network configurations (/Library/Preferences/SystemConfiguration/preferences.plist) also contains PPP options for each specific network service. After some searching around, I found that there are several keys that seem promising (MSCHAP2, etc.). But these keys take a string value and I have no clue what they should be. These keys are defined in SCSchemaDefinitions.h file.
    Any ideas?
      Mac OS X (10.4.9)  

    Hi Brian,
    I just tried to check all of ADDT´s "includes" files for any internal references (read: "require" or "require_once" statements) to the file "tNG_config.inc.php". So far I can only see this file referenced in the file "tNG.inc.php" (within the "$KT_tNG_uploadFileList1" array).
    So what could this mean ? Maybe you´ll have to make copies of the the original "tNG.inc.php" as well and save them as, say, "tNG.inc_ital.php" file plus make sure that these copies internally point to a different "tNG_config_ital.inc.php" file -- because it´s always the first mentioned file which gets referenced from e.g. an ADDT login page (see the "Load the tNG classes" - part)
    I want to use ADDT’s User Registration Wizard and I have looked at all the neat stuff in the Control Panel/Login Settings
    The Control Panel will always update the main "tNG_config.inc.php" file, so any further modifications will have to become manually applied to the custom files you´re creating.
    Cheers,
    Günter

Maybe you are looking for

  • Windows 8.1 Metro Applications not functioning over VPN

    Has anyone been able to resolve this in a corporate environment?  We are not looking for loopback exemptions with fiddler, but rather a secure method to configure metro applications to use a proxy.  If we manually set the proxy configuration, it work

  • What MBP do I have?

    I have a MBP that's an 1226. How do I tell if that's a "late 2008/2009" MBP? (I bought it used.) TIA

  • PDF's missing random words

    I'm a college student who uses Safari to do alot of online readings for classes. I've looked through many of these threads but haven't found anyone with this same problem. At times when I'm using preview to look at pdf's, words will just randomly be

  • Applecontrolpanel.exe for a 32-bit Windows 7 OS?

    Hi anybody can share their applecontrolpanel.exe for a 32-bit Windows 7 OS? I need it to adjust the brightness setting for my 27-inch ACD, thank you so much in advance.

  • Photo Mail

    I'm just finishing putting together a new computer with Windows 7-64, PSE8, and Outlook 2010.  PSE8 does not recognize Outlook as a valid choice under Share.  One of the main features I use PSE for is the Photo Mail function.  Are there any suggestio