How to select multiple substring in JTextarea at the same time?

I want to select multiple substring in a jtextarea at the same time by select(start,end) method, turns out only the last substring is highlighted, how to implement my goal?

jamesybaby wrote:
What you got so far? A SCCEE would be nice?my aim is to search key words in jtextarea and highlight all matched result.
package frame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FrmSelect extends JFrame {
    public FrmSelect() throws HeadlessException {
        setSize(800, 600);
        final JTextField tfKey = new JTextField();
        tfKey.setPreferredSize(new Dimension(200, 20));
        final JTextArea taContent = new JTextArea();
        JScrollPane jsp = new JScrollPane(taContent);
        tfKey.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String key = tfKey.getText();
                String content = taContent.getText();
                String[] splited = content.split(key);
                Pattern ptn = Pattern.compile(key, Pattern.CASE_INSENSITIVE + Pattern.MULTILINE);
                Matcher matcher = ptn.matcher(content);
                taContent.requestFocusInWindow();
                while (matcher.find()) {
                    int start = matcher.start();
                    int end = matcher.end();
                    taContent.select(start, end);
        add(tfKey,BorderLayout.SOUTH);
        add(jsp,BorderLayout.CENTER);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    public static void main(String[] args) {
         new FrmSelect();
}please copy below into the jtextarea and type key 'prop' in the jtextfield, press return.
prop1adsfasfd
prop2adsfasdfadsf
prop3asdfasdfasdf

Similar Messages

  • Dispatch center - Select multiple tasks for scheduling at the same time

    Hi!
    I need a consultation regarding Dispatch center. Is there a functionality to select multiple tasks for scheduling at the same time for one resource?
    Please, guys, this is urgent.
    Jan

    You can schedule a single task or multiple tasks automatically directly from the
    dispatch center. The scheduling criteria applied come from Advanced Scheduler.
    Make Sure, you have the advanced scheduler. With out Advanced Scheduler and by just using Advice, you can only assign one task at a time.
    HTH
    ps: for more information, refer Field Service User Guide, "Scheduling Tasks"

  • Numbers: how to edit multiple "sheets" "tables" all at the same time

    I have read earlier posts from 2004 about this topic. Hoping things have changes.
    I have 19 sheets/tables in a numbers file "Pigeonrecords.numbers". I would like to globally alter all of them a one time as new columns or rows are needed and or data that applies to all the sheets/tables. How do I do that?
    Thank you.

    You can do a few things. For instance, you can select all the tables you want to modify and you can add a new row or column to each.

  • How to configure multiple listeners to listen for the same instance.

    Hello everyone,
    I am running oracle database 11g and I want information regarding how to configure multiple listeners to listen for the same database instance. Actually I know how to configure more than one listener but the main thing that I am confused about is when we create listener.ora file, do we have to statically register the database instance with both the listeners or the instance will register itself with both the listeners.
    According to my knowledge the instance will register with the listener specified by LOCAL_LISTENER parameter and we cannot have more than one value for this parameter.
    Please only give detailed answers with example as I am tired of simple answers with details that I already know.

    Hello,
    Yes, it can make sense to have several listener for one Oracle instance. For instance you may have one listener for the applications another listener for DBA administration tasks as well as one listener dedicated to dataguard broker. It is not possible to have several listeners listening on the same IP and Port.
    By default the database try to automatically register to a listener on port 1521. To instruct the instance to register to a specifc list of listeners you can add in the init.ora the local_listener parameter with an alias definition:
    i.e
    local_listener=MY_SET_OFF_LISTENERS
    in your tnsname.ora add an entry called:
    MY_SET_OFF_LISTENERS_LOCAL= (ADDRESS_LIST=
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1530))
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1531))
    (ADRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1532))
    In this sample your instance will register to three listeners listening on respectively port 1530, 1531 and 1532
    If you want your clients can be balanced over the 3 listeners

  • In windows how do we install and activite multiple versions of tuxedo at the same time ?

    Hi All,
    In windows how do we install and activate multiple versions of tuxedo at the same time ?
    Advance wishes

    You can run different versions of Tuxedo on the same server, as long as they are installed in different directories.
    See PeopleTools 8.53 installation manual Task 3-1: Installing Oracle Tuxedo
    You can install Oracle Tuxedo once for each release on a machine, regardless of the number of PeopleSoft
    applications or databases the server supports. For example, if you are a PeopleSoft 9.1 customer and have
    Oracle Tuxedo 6.5 installed, you may install Oracle Tuxedo 6.5 and Oracle Tuxedo 11gR1 on the same
    machine in separate directories. For example:
    On Windows, you may install into C:\oracle\tuxedo11gR1_VS2010 and C:\tux65.
    On UNIX, you may install into /home/oracle/tuxedo11gR1 and /prod/tuxedo/6.5.
    E-TUX: Can Multiple Versions of Tuxedo Coexist on One Physical UNIX or Linux Server? (Doc ID 607828.1)

  • IPhone - how to sync with iPhoto and Aperture at the same time ???

    I'm having a really hard time with syncing my photos - I'm using iPhoto and Aperture on my Mac. When I launch iTunes and start managing my iPhone, it seems like I should be able to sync photos from a variety of sources all at once (iPhoto, Aperture, other folders).
    However, whichever option I select in the photos drop-down becomes the only libraries that are available to sync. What I mean is that if I select some of the Albums in my iPhoto list and sync those, when I later drill down to Aperture and select albums from there and perform a sync - then the previously synced/loaded albums and photos from iPhoto are automatically removed from the iPhone.
    Why can't I sync between multiple photo albums / sources at the same time? This is incredibly annoying.

    Here's how I solved this problem:
    In Aperture, select File -> Import -> iPhoto Library
    Then under the "Store Files" dropdown, be sure "In their Original Location" is select. This will allow Aperture to see your iPhoto library, but it will be managed by reference rather than phyisically imported.
    Now, in iTunes, select Aperture as the application from which you want to synch photos, and select the option to synch specific albums.
    You should be able to see the names of albums in iPhoto as well as those created in Aperture.

  • New Camera RAW in Photoshop CC 2014 won't open multiple Panasonic RAW (.rw2) at the same time from Windows Explorer.

    New Camera RAW in Photoshop CC 2014 won't open multiple Panasonic RAW (.rw2) at the same time from Windows Explorer.  If I select 2 raw files and click "Open" Camera RAW will only open 1 raw, then when I click "Done" it will close and open the second, sequentially.  Previous Photoshop CC and RAW worked fine, it would open mulitple RAW at the same time.  How do I fix this?

    If it worked for you that way previously there isn't much to comment about. I just tried opening multiple images from Windows Explorer with Photoshop CS6 and Camera Raw 8.6, and the first image would open and when I clicked cancel then the second image would open. But if I wanted multiple images opened in Camera Raw to work on them simultaneously it was necessary for me to open them from Bridge. I just did it as an experiment because I normally use Lightroom. Anyway, IF it was a feature at one time to work as you described, it doesn't seem to be that way now.

  • How to change keyword in many pictures at the same time?

    I gave a big series of pictures the wrong keywords. Now, I can't figure out how to change them (besides one by one...).
    If I select e.g. 10 pictures in Library-mode, how to change keywords on them all at the same time?

    Make sure you are in Grid View, primary monitor (if you have two), select 10 pictures and type (or delete) the keywords in the Keywording panel in the left upper corner.
    Make sure the Metadata->Show Metadata for Target Photo Only is unchecked in the menus. Otherwise your edits will only apply to the primary selected (most selected) image.

  • How do I get two screens up at the same time

    Hello.
    How do I bring up two screens at the same time so I can work on one and refer to the tutorials on the other?

    Hello Jazzy6491
    All you should need is another monitor and the appropriate adapter for it you plug into you MacBook Pro. Check out the article below on how to use multiple monitors with your Mac.
    OS X: How to use multiple displays with your Mac in Mountain Lion and earlier
    http://support.apple.com/kb/ht5019
    Regards,
    -Norm G.

  • How do i start video and audio at the same time in ios

    How do i start video and audio at the same time in ios?
    I have tried a lot of different ways but i cant figure it out?
    I can get the sound and animation (timeline) to start playing.
    There is no problem to start the video and the animation at the same time.
    But i cant get both the video and the audio to start playing when i press a button.
    It works great in OSX and on windows?
    Here is an example:
    // insert code for mouse click here
    // Play an audio track
    sym.$("_1")[0].play();
    // Play a video track
    sym.$("host")[0].play();
    // Play the timeline at a label or specific time. For example:
    // sym.play(500); or sym.play("myLabel");
    sym.play("marker1");

    If the game has sound in it (and possibly even if it doesn't) it may be overriding the Music app and causing it to stop playing - in which case there is nothing that you can do about it.

  • How far will the extreme reach and how many users can be on there at the same time?

    How far will the airport extreme reach and how many users can be on there at the same time?

    Last question first, since that is the easy one......approximately 50 (fifty) users for wireless depending on how active each user might be.
    The first question is much more difficult, as distance is not really the issue with wireless.....obstructions are the issue.
    A wireless signal can easily travel 300 feet or more with no obstructions in the signal path.
    But, a typical wall of sheetrock or wallboard in a home will absorb....on average....15-20% of the wireless signal. Brick or adobe will obviously absorb much more. A ceiling....because it is thicker....will absorb about 25-35% of the signal.
    So, if the wireless signal must pass through several walls and a ceiling, there won't be much, if any, of the signal left....even though the distance that the signal travels is not great...for example, 20-25 feet.
    Other wireless networks around you at the neighbors can also affect the relative strength of the wireless signal.
    The bottom line....locate the AirPort Extreme where wireless devices will receive a signal with the least amount of obstructions in the signal path. Your actual performance cannot be predicted in advance. You will not know how well the AirPort Extreme works for you until you try it out in your home.
    If you find that the signal does not reach as far as needed,  you will need to add additional "extenders", like an AirPort Express to provide more signal coverage.

  • How to sync with two computers not at the same time, I'm registerd with one computer

    How to sync with two computers (not at the same time), I'm registered with one computer and am trying to connect with second computer with same iPhone. To sync the first time with the second PC "Firefox Sync Option tells me Create New account or Connect, when I connect it gives me a Passcode and on iPhone it also gives me a Passcode, than how do I connect? Both the iPhone and PC gives me a Passcode and have now idea what to do with them.
    Where do I find my Sync Key ? so I can install manually if it works ?

    Use the Sync Key ''(Recovery Key)'' from the PC that you used to initially setup your Firefox Sync service, when setting up that 2nd PC with Sync. You need to use '''Add a device''' to setup the 2nd and subsequent devices on a Sync account. <br />
    https://support.mozilla.com/en-US/kb/add-a-device-to-firefox-sync

  • How many people you can do facetime at the same time?

    how many people you can do facetime at the same time?

    As many faces as the screen will fit. 27" iMac can fit quite a lot of faces.

  • How can I run 2 Dreamweaver windows at the same time?

    How can I run 2 Dreamweaver windows at the same time on my
    PC?
    basically I have 2 monitors and I want to edit CSS on one
    monitor and have the html page open on the other so I can quickly
    look from one to another with in a split second instead of taking
    that extra time to switch back and forth using the tabs at the top,
    I know I should probably invest into a mac so i can work out side
    of the Dreamweaver application window and I will in the future but
    is there any way i can do this on my windows XP pro PC?
    Thank you
    Maurice

    Open the CSS in DW, and use F10 to open the Code Inspector.
    Place the
    latter as needed.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Random_Yggdrasil" <[email protected]> wrote
    in message
    news:gi2htb$j4j$[email protected]..
    > How can I run 2 Dreamweaver windows at the same time on
    my PC?
    > basically I have 2 monitors and I want to edit CSS on
    one monitor and have
    > the
    > html page open on the other so I can quickly look from
    one to another with
    > in a
    > split second instead of taking that extra time to switch
    back and forth
    > using
    > the tabs at the top, I know I should probably invest
    into a mac so i can
    > work
    > out side of the Dreamweaver application window and I
    will in the future
    > but is
    > there any way i can do this on my windows XP pro PC?
    >
    > Thank you
    > Maurice
    >
    >
    >

  • JVM 1.3.1_06 Solaris 8 (sparc) multiple jvm's crash at the same time

    Hi All,
    I had multiple jvms crash all at the same time today morning, i was wondering if anyone had any similar issues with 1.3.1_06:
    Only a few jvms left an hs_errpid.log: here is the one with the most info:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : 10 occurred at PC=0xff02f8f8
    Function name=VerifyClassCodes
    Library=/www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/libjava.so
    Current Java thread:
    at java.lang.Shutdown.halt(Native Method)
    at java.lang.Shutdown.exit(Shutdown.java:209)
    at java.lang.Terminator$1.handle(Terminator.java:33)
    at sun.misc.Signal$1.run(Signal.java:193)
    at java.lang.Thread.run(Thread.java:479)
    Dynamic libraries:
    0x10000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/bin/../bin/sparc/native_threads/java
    0xff350000 /usr/lib/libthread.so.1
    0xff340000 /usr/lib/libdl.so.1
    0xff200000 /usr/lib/libc.so.1
    0xff330000 /usr/platform/SUNW,Ultra-Enterprise/lib/libc_psr.so.1
    0xfe400000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/hotspot/libjvm.so
    0xff2d0000 /usr/lib/libCrun.so.1
    0xff1e0000 /usr/lib/libsocket.so.1
    0xff100000 /usr/lib/libnsl.so.1
    0xff0d0000 /usr/lib/libm.so.1
    0xff1c0000 /usr/lib/libmp.so.2
    0xff090000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/native_threads/libhpi.so
    0xff060000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/libverify.so
    0xff020000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/libjava.so
    0xfe7d0000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/libzip.so
    0xfe3e0000 /usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.2
    0xfe390000 /www/gmgwh/weblogic/jdk/j2sdk1_3_1_06/jre/lib/sparc/libnet.so
    0xfe230000 /usr/lib/nss_files.so.1
    0xfe160000 /www/gmgwh/weblogic/6.1/sp4/lib/solaris/libmuxer.so
    0xfd0e0000 /usr/ucblib/libucb.so.1
    0xfd090000 /usr/lib/libresolv.so.2
    0xfd050000 /usr/lib/libelf.so.1
    0xfafd0000 /app/oracle/product/8.1.7.4/lib/libocijdbc8.so
    0xe1800000 /app/oracle/product/8.1.7.4/lib/libclntsh.so.8.0
    0xfafb0000 /app/oracle/product/8.1.7.4/lib/libwtc8.so
    0xfaf90000 /usr/lib/libsched.so.1
    0xfaee0000 /usr/lib/libaio.so.1
    Local Time = Wed Jan 19 09:09:31 2005
    Elapsed Time = 22367
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.3.1_06-b01 mixed mode)
    #

    hi there
    i would direct my efforts to search for the culprit on who generated the signal (either a INT, TERM or HUP). The crash occurred is just but another side-effect. The VM received a shutdown signal and shld exit. Just that while exiting, it crashed.
    There is this bug
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4904881
    Which is pretty rare. I am not sure if you are encountering this bug but if u have a core, a pstack of the core should show > 2 threads with doing the signal shutdown.

Maybe you are looking for