Selecting two JText Area at a time

Hi All,
I am creating an GUI application for diff'ing two text files. For showing the two text files I am using the JTextArea and now the problem is when I show difference between two fields I have to select text in the two JTextArea Simultaneously so that we can see the differences between two lines. but I don't know how to select two Jtext area at a time.
Please help me doing this.
If not possible somebody please suggest me some alternative for this.
Regards,
Anoop

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class HighlightText extends JFrame {
    private JTextArea textarea1;
    private JTextArea textarea2;
    private JButton pressJButton;
    public HighlightText() {
        super( "Highlight Text" );
        Box box = Box.createHorizontalBox();
        final String s = "Here is the first line.\n" +
                "Here is the second line.\n" +
                "Here is the third line.\n" +
                "Here is the fourth line.\n";
        textarea1 = new JTextArea(s);
        box.add( new JScrollPane( textarea1 ) );
        textarea2 = new JTextArea(s);
        box.add( new JScrollPane( textarea2 ) );
        pressJButton = new JButton( "Press" );
        box.add(pressJButton );
        highlight(textarea1, 12,17);
        highlight(textarea2, 12,17);
        pressJButton.addActionListener(
                new ActionListener() {
            public void actionPerformed( ActionEvent event ) {
                highlight(textarea1, 36,42);
                highlight(textarea2, 36,42);
        getContentPane().add(box);
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setSize( 600, 300 );
        setLocationRelativeTo(null);
    public static void main( String args[] ) {
        new HighlightText().setVisible(true);
    // Creates highlights
    private void highlight(JTextComponent textComp, int selectionStart, int selectionEnd) {
        // First remove all old highlights
        removeHighlights(textComp);
        try {
            Highlighter hilite = textComp.getHighlighter();
            // Add highlight using private painter
            currentHilite = hilite.addHighlight(selectionStart, selectionEnd, textPainter);
        } catch (BadLocationException e) {
    private Object currentHilite;
    // Removes only our private highlights
    private void removeHighlights(JTextComponent textComp) {
        Highlighter hilite = textComp.getHighlighter();
        Highlighter.Highlight[] hilites = hilite.getHighlights();
        for (int index=0; index<hilites.length; index++) {
            if (hilites[index].getPainter() instanceof TextPainter) {
                hilite.removeHighlight(hilites[index]);
    // An instance of the private subclass of the default highlight painter
    private Highlighter.HighlightPainter textPainter = new TextPainter(Color.yellow);
    // A private subclass of the default highlight painter
    private class TextPainter extends DefaultHighlighter.DefaultHighlightPainter {
        public TextPainter(Color color) {
            super(color);
}

Similar Messages

  • BAPI_ALM_ORDERHEAD_GET_LIST to select two different order at a time (urgent

    hello all ,
    Using BAPI_ALM_ORDERHEAD_GET_LIST i want to select two different orders at a time . As we do in IW38 using select single vaules(1) .
    i want to know how to pass the selection .
    Up to know i have tried like this :
    FIELD_NAME                     S OP LOW_VALUE
    OPTIONS_FOR_ORDERID            I EQ 500460
    OPTIONS_FOR_ORDERID            I EQ 500400
    But i am getting only the first order . But i want both order numbers .
    So please help me on this .
    Thanks are regards ,
    Prem

    Just for information. The following IT_RANGES fields map to the IW38 checkboxes at the top of the selection-screen:
    SHOW_DOCUMENTS_IN_PROCESS      IW38 - Outstanding (CRTD)
    SHOW_OPEN_DOCUMENTS                  IW38 - In process (REL)
    SHOW_COMPLETED_DOCUMENTS       IW38 - Completed (TECO and CLSD)
    SHOW_HISTORICAL_DOCUMENTS       IW38 - Historical
    If you want to select TECO/CLSD orders, then you would use the following in IT_RANGES:
    SHOW_DOCUMENTS_IN_PROCESS      I EQ
    SHOW_OPEN_DOCUMENTS                  I EQ
    SHOW_COMPLETED_DOCUMENTS       I EQ X
    SHOW_HISTORICAL_DOCUMENTS       I EQ
    As you then said, you need to filter out the CLSD statuses using:
    OPTIONS_FOR_STATUS_INCLUSIVE I EQ TECO
    I suspect this would be a more efficient way of selecting the data, but you'd need to check.
    PeteA

  • How to select two things at the same time ?

    Hey guys, i'm French and I need your help !
    I'm working everyday on iWork and especially Pages.
    How to select two parts of a text at the same time ?
    Before we only need to select one, to press the "cmd" button and then to select another part. It doesn't work anymore!
    Thanks for you help
    and sorry for the mistakes !

    Hey guys, i'm French and I need your help !
    I'm working everyday on iWork and especially Pages.
    How to select two parts of a text at the same time ?
    Before we only need to select one, to press the "cmd" button and then to select another part. It doesn't work anymore!
    Thanks for you help
    and sorry for the mistakes !

  • Two business area in one entry

    hi..
    i received a payment from customer.when i check this voucher by fb03 than in a single document it is showing Business Area 1100 and 1200 both. How the System is allowing to select two business area in one entry?
    Thanks & regards
    Rekha sharma

    Hi
    At the time of initial posting of the document itself you might have posted two line items with a two business areas.  Try to post only one line item.  There is no standard control to stop the posting of 2nd line item by Standard SAP.
    Cheers
    Srinivas

  • Diversity and trying to conver two different areas

    So the whole purpose of diversity is to provide/improve coverage in a same area.  Basically two antennas placed with a reasonable distance from each other and the concept is that one antenna might receive a better signal than other and then both signals can be combined to get a single stream.  End result better communication.
    Now something I have noticed that people are doing is taking the two antennas and putting them like 25 to 50 feet apart with diversity enabled trying to cover two different areas.  At times two different rooms so like one antenna is in one room and second one is in another room with a concrete wall between them.  Apparently they are saying that it is working for them.  I'm trying to understand the logic behind that how something like that wouldn't cause issues unless they have clients only on one side?

    I've seen set-ups like this before and people at the site can (and will) say that it's "working".  
    Until I get a wireless sniffer out or do some scanning, it seldom works.  They will say that it's working purely for political (don't want to get themselves into trouble) and/or financial (they can't afford to put two APs) or both.  
    This may work (somewhat) in 802.11a/b/g but stick 802.11n/ac and I'm certain it won't work.  When I mean it won't work, I mean you won't see the full benefit of connection speeds of >155 Mbps. 

  • Running a Mac G3, having been using a Laserwriter Select 360, but it and two others are now dead. What is the next best or better printer to use?

    I am running a desktop beige Mac G3 and have been using a Laserwriter Select 360, but it an two others are now dead.
    What is an equal or better printer to use with the Mac?

    Hey, BD, I looked at Brothers last night in connection to this questiona and it looks like their newest/current laser print-only units go back to 10.4 but no further.
    Brother is the best hope but the OP may need to look for an older model still in stock. For example, for our older Brother HL5250DN, they still show OS9 drivers:
    http://welcome.solutions.brother.com/bsc/public/us/us/en/dlf/download_top.html?r eg=us&c=us&lang=en&prod=hl5250dn_all
    Gary, web-check for stores that still have older models on teh shelf. You can also look at "newer-but-not-new" and then use the Brother site to check for OS9 drivers.
    Founds some of my model on eBay:
    http://www.ebay.com/sch/i.html?_nkw=Brother+HL-5250DN
    We paid US$199 for ours new about seven years ago. It's been a real workhorse and trouble-free. Well, except for the time my wife tried to feed it a odd paper stock that was not on the printer's official diet!
    A Beige G3 consideration: The Big Beige doesn't come with USB ports. You must add a PCI USB adaptor card, and the ones that worked in the Beige are harder to find today.
    However, the Beige has built-in ethernet so if you get a printer with an ethernet connector, you will be in bisiness with neither the expense of an extra adaptor card nor the occasional buttheadedness of USB printing. The "N" in our Brother model designates it as a network printer so it has an ethernet port. Many others do also.

  • HT1150 I have two shared printers and I want to be able to select the printer when it is time to print without having to set a default EACH time.  Can I just have a prompt to ask me which printer to use???

    I have two shared printers and I want to be able to select one printer when it is time to print without having to set a default EACH time.  Can I just have a prompt or dialog box that will ask me which printer would you like to use???  The only options I can find are "default" and "Last printer used" which means I must go into the Print & Fax area and change the default EACH time I want to print???  Seems very low tech.....

    junnybug wrote:
    Can I just have a prompt or dialog box that will ask me which printer would you like to use???
    In most cases you get this dialog box every time you print. It is called the print dialog and normally when you print, a print dialog appear showing the printer that is to be used. Which printer you see will be based on what you have set in Print & Fax as you mention. But regardless of what you have set there, you still have the option to change the printer via the print dialog.
    If you are using an application that does not show the print dialog, like MS Word and that stupid "print one copy" print icon in the toolbar, then you can often change the action the print icon uses so that the print dialog appears.

  • How do I go directly from one frame to another particular frame which is far away in the time line? (e.g the two frames are separated by 100 frames)

    How do I go directly from one frame to another particular frame which is far away in the time line? (e.g the two frames are separated by 100 frames). I mean, is it possible to take the playhead from one frame to another frame directly which is 100 frames away in the time line? Thanks for any reply.

    In the Timeline, go to the first frame and press M to put a marker on it. Go to the other frame you want to jump to and put a marker on that one too.
    Now press Ctrl+Semicolon to go to the previous marker - or Ctrl+Comma to go to the next marker.
    Andy

  • Selecting only one row at a time

    Hi experts,
    i have following doubt regarding selecting rows from a db:
    Is there any way of selecting only one row AT A TIME from a dabase just to collect the data in rows instead of in a unique document containing all the rows?
    I would like you to ellaborate on this as i need to send only one row to the IE, and then other row, and so on... without throwing any error!
    I have seen that there are SELECT SINGLE and SELECT UP TO 1 ROW, but these two methods are only useful when retrieving only one row, and that does not match my requirements. I need to process all the rows but one by one..
    I know that we can use the receiver jdbc adapter as if it was a sender by means of its specific datatype, but how to do it row by row??
    Hope i had explained well..
    Thanks in advance and best regards,
    David

    Hi kiran,
    Yes, my table has 5 not null fields but i am selecting and updating fixes values so i think that I will definetely go for the next solution:
    SELECT * FROM t1 WHERE status='0' and ROWNUM<2;
    UPDATE t1 SET status='1' WHERE status='0' and ROWNUM<2;
    My only concern is if the update will take the same row that the select.... BTW, I think it will
    ..What do you guys think?
    I ve been trying to operate with your proposed queries but i received some errors. Your queries are very interesting but i think that with the above ones i meet my requirements as the status field will be 0 for not processed rows and 1 for precessed ones (and the update will look for the row that meets the same 'where' clause than the select, and then, and only then, it will set status='1').
    The only thing i have to care about is what i questioned before.
    Thanks a lot and best regards,
    David

  • I have three Blue Yeti USB Microphones, and when I try to create an aggregate device in Audio MIDI on my MBP it lets me select two microphones but not the third. I need all three for a podcast, any solutions?

    I have three Blue Yeti USB Microphones, and when I try to create an aggregate device in Audio MIDI on my MBP it lets me select two microphones but not the third. At first I thought maybe the third microphone was just defected or something but I tested the mic individually and it works fine. It'll let me use two Blue Yeti's and another microphone but not three Yeti's at once.

    David Boroditsky wrote:
    The problem is that the mac chokes on having 2 identical mics attached at the same time.
    Ive had 2 identical USB AT2020 mics connected at the same time on both macbook pro and macbook Air.
    The "Yeti" mics, are, lets say undesirable, and low to mid computer consumer mics.

  • Select query is taking lot of time to fetch data.....

    Select query is taking lot of time to fetch data.
        SELECT algnum atanum  abdatu abzeit abname abenum bmatnr bmaktx bqdatu bqzeit bvlenr bnlenr bvltyp bvlber b~vlpla
               bnltyp bnlber bnlpla bvsola b~vorga INTO TABLE it_final FROM ltak AS a
                       INNER JOIN ltap AS b ON  btanum EQ atanum AND algnum EQ blgnum
                       WHERE a~lgnum = p_whno
                       AND a~tanum IN s_tono
                       AND a~bdatu IN s_tocd
                       AND a~bzeit IN s_bzeit
                       AND a~bname IN s_uname
                       AND a~betyp = 'P'
                       AND b~matnr IN s_mno
                       AND b~vorga <> 'ST'.
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Mar 27, 2011 12:05 PM

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • Using geocode in a map based on a view where two datasets are joined

    Hi,
    I'd like to create a map based on a view in which two datasets are joined, where one of the datasets has a geocode column.
    Unfortunately this is not working... It seems that a custom view where two datasets are joined together where one of them has a geocode column makes the geocode column invisible for the map component.
    The following cases do work but we like to combine them so that we can combine different datasets in Studio without using the Integrator:
    - I can create a custom view in which we join two datasets > the view can be used as a source for different component but not the map component (it seems that the geocode column is not found)
    - I can create a custom view with a geocode column in it and that one can be used as a source for a map
    What I'd like to show is that it is possbile to have one datasets coming from a source system and that it is easy to combine an additional excel sheet with geo-information and maybe another excel sheet with different measures. This should be possible since you can join different datasets together in a custom view.
    Thanks in advance,
    Richard

    Oh sorry, we have two base views and one custom view:
    base view TRIS_Omzet which gets it data from an OBI server and has data like revenue, customer, time, etc.
    base view Endeca_Klanten which gets it data from an excel sheet, this view contains the name of the customer and the geocode of the customer's location
    We created one custom view (Omzet_Geo) where the two base queries are joined together using the following query:
    DEFINE V1 AS SELECT
    "Endeca_Klanten.Klanten" AS Klant,
    "Endeca_Klanten.Coordinaten" AS Coordinaten
    from Endeca_Klanten;
    DEFINE V2 AS SELECT
    "TRIS_Omzet.Naam_Consultant" AS Naam_consultant,
    "TRIS_Omzet.Jaar" AS Jaar,
    "TRIS_Omzet.Jaar_week" AS Jaar_week,
    "TRIS_Omzet.Actual" AS Actual,
    "TRIS_Omzet.Omzet" AS Omzet,
    "TRIS_Omzet.Partij" AS Partij,
    "TRIS_Omzet.Uren" AS Uren
    FROM TRIS_Omzet
    DEFINE Omzet_Geo AS SELECT
    V1.Klant AS Klant,
    V1.Coordinaten AS Coordinaten,
    V2.Naam_consultant AS Naam_consultant,
    V2.Jaar AS Jaar,
    V2.Jaar_week AS Jaar_week,
    sum(V2.Actual) AS Actual,
    sum(V2.Omzet) AS Omzet,
    V2.Partij AS Partij,
    sum(V2.Uren) AS Uren
    from V1
    right join V2
    on (V1.Klant=V2.Partij)
    group by Klant, Coordinaten, Naam_consultant,Jaar,Jaar_week,Partij
    Our view definition in the GUI looks like the following, as shown in the screenshots the datatype of the coordinated column is a Geo column both in the base view and the custom view. However the view still can't be selected to be used as a source for the map component.
    The two base views:
    The custom view:
    regards,
    Richard

  • Multiple clip selection- way to find out total time?

    I have a time line that has (as an example) 20 clips in it. Is there a way to select two or more clips and be able to get the total time of both the selected clips? For example if one clip is 4 seconds and thee second is 3 seconds and the third (or more) is one second, the total time of those clips is eight seconds.
    Right now, the only way I know how to get this information is to select those clips, paste them in a new timeline and then look at the total length in the time window on the timeline. I'm also aware I can get the time in each individual clip in the clip properties, but then you need a calculator to get the exact time.
    Is there another way?
    Thanks.
    Jonathan

    Hi -
    if the clips are adjacent in the timeline then just select the clips and type Shift -A, you will get an in and out marking that includes all the adjacent clips you have selected. You can read this duration in the timecode window that is in the upper left above the canvas.
    If you mean you want to randomly select clips and see what the total combined duration of those selected clips is, I am not aware of a way to do that, but would be interested to learn if it is possible.
    Hope this helps
    Message was edited by: Meg The Dog to correct typo

  • To move an image behind a part of our "first picture", as if two layers are overlapped !

    Hello,
    I'm french, and I already posted a question a few times ago, on this forum and I was very satisfied with your quick answers, so I come ask again a little question...
    It's about Photoshop CS6 and I would like to know if it's possible to move an image behind a part of our "first picture", as if two layers are overlapped (the first picture and the picture that I add !) and one layer was partially hidden by the first !
    It's quite complicated to understand and explain... I know ... and I'm very sorry ...
    Example: If I want to move a book behind furniture (which is located in the center of my "background" or "first picture", surrounded by a nonuniform setting !), so to see only part of the book and the other part is hidden by the furniture ! Like the picture below (where we see that the "Coraya" is behind the desk !!) :
    I thank you in advance for all your quick responses and I congratulate you in advance to your understanding and your professionalism about Photoshop !
    Makarsh

    Makarsh,
    One easy way to accomplish that look is to add a Layer Mask to the "book" Layer, in the shape of the furniture, that you wish to hide part of the book behind.
    That would probably be easier by creating a Selection for that part of the furniture, with the Selection Tool of your choice. I personally like to do such work with the Pen Tool (creates a Path), as it is very exact. However, if one is not comfortable with the Pen Tool and Paths, then the Lasso (perhaps constraining it for straight lines) might be easier. If you do use the Pen Tool, when complete, go to the Paths Panel, and from the little arrow in the top-right, choose Make Selection.
    Then, with that Selection still active, go to the book Layer, and click on the Create Layer Mask icon, at the bottom of the Layers Panel.
    If necessary, you can do touchup to that Layer Mask, after it has been created.
    Good luck, and hope that helps.
    Hunt

  • I have ripped all of my Cds into iTune, now I cannot find where some of the artists have been filled, not all the artists are listed, yet others are listed multiple times as they play with other groups. How do I list all one artist under his name? I know

    Sorry this will appear pretty basic stuff.  I have ripped all my Cds into iTunes, but in starting to make playlists it is apparent that some artists are listed multiple times as they appear with different bands, and others do not appear at all.  I have tried searching different categories, compilations etc, and Finder box does not bring them up.
    My questions are:-
    Do I need additional software to manipulate my tunes in iTunes?
    If so what is suggested?
    or if not:-
    How can I re arrange the tunes so that they appear only under one artist?
    How do I make my "lost" artists tunes appear?
    Thanks for any advice.

    I am not really following what the problem is here.  Artists are listed in the Artist field.  I guess you could stick individual artists in a band in a field such as comments, but then you would have to include searching the comments field in your search.  In which fields are these names located?
    How are you making these playlists? Are these smart playlists or are you just dragging tracks to a playlist?
    Are you doing this search with Finder's find or with iTunes' search?
    If I knew exactly what it was you were trying to do I could tell you if you need addditional software.  In reality though there isn't "additional software" for iTunes.  There's Applescript plugins but I don't see how the ones with which I am familiar would have anything to do with searching for artist names.
    How can I re arrange the tunes so that they appear only under one artist?
    Steve MacGuire aka turingtest2 - iTunes & iPod Hints & Tips - Grouping Tracks Into Albums - http://www.samsoft.org.uk/iTunes/grouping.asp (older post on Apple Discussions http://discussions.apple.com/message.jspa?messageID=9910895)
    Quick answer:  Select all the tracks on the album, File > get info, and either give them all a single "album artist", or check the "compilation" flag (as in https://discussions.apple.com/message/17670085).
    If these are from multiple-CD sets you may also need to enter the appropriate information in the disc number fields.

Maybe you are looking for