Selecting a portion of a JComponent

Hi,
I need to provide the ability for a user to select a portion of a JComponent. My final aim is to obtain the Rectangle coordinates for the selection, but while selecting, the user should be able to see a box around the selection area as he is dragging his mouse while selecting. How can I go about doing this?
Thanks.

OK, I get the point, but I'm still unclear on how my classes will need to be structured. Here's how I would like it to be:
I have a class A in which I create my JFrame, and add several other components such as JPanel, JButton, JLayeredPane etc etc to the frame. Then, from class A, all I would want to do is call B b = new B(component), where component can be anything that's been added to my JFrame.
Now, the B class would really be the selection utility class, in which I do all the required initialization, look for mouse events and mouse motion events, and draw the box around the selected area of the component in question. Now since this B class is just a utility class, I can't really make it extend the component class so that I can write my own paintComponent method.
Am I making sense? If you could please provide some basic code outline/structure on how to arrange my classes, that's be very helpful.
Thanks.

Similar Messages

  • I can't select a portion of a scanned page

    I often have documents scanned into PDF format at two different copy shops. Sometimes I want to use the Acrobat 8 or Adobe Reader 7 selection tool to select a portion of a scanned page and then edit that selection in Photoshop.
    When I open scan from one of the shops (which uses Acrobat 4 for scannng) and choose the selection tool, the cursor turns into a crosshair and I am able to then marquee-select a portion of the scanned image, copy the selection and then edit the selected image in Photoshop.
    When I open a scanned image from the other copy shop (which uses Acrobat 7 for scanning) and choose the selection tool, the cursor remains an arrowhead and I cannot select any portion of the scanned image.
    Can you please tell me how to correct this problem? Thanks

    You can only edit an entire graphic, not parts. In addition, you can not do the edit in Reader. In both of the cases you describe, you should be able to select the image to edit. The process you are using sounds like a graphic copy (at the screen resolution) which is far from an optimal process for getting the graphics. You can save all graphics to the hard drive and edit those, retaining all of the resolution of the original.
    In terms of the two cases, it sounds like the second shop may have set security to not allow copying of the graphic screen.

  • Acrobat 9 Standard - Selecting a portion of an image

    I have opened a pdf file and I am trying to select a portion of an image for copying it into a Word file.  I have clicked on the Select Tool, but, when I move the Select Tool on the image, it never changes to a cross and I cannot select the portion in which I am interested.  Could somebody help? 
    Many thanks

    Thanks for your reply.
    The problem actually is that the file is protected.

  • Ok really now...has anyone figured out a new way to select a portion of a project and output just that part?? Or is it still a 20 step process??

    Ok really now...has anyone figured out a new way to select a portion of a project and output just that part?? Or is it still a 20 step process?? What is the best/fastest way to give my client a teaser clip??

    Still a 20 step process, many ways to approch it. Duplicate project and selectively delete everything around it. Or select and copy what you need. I think it could be a year before apple makes that step a 2 or 3 step process.

  • Selecting a portion of an image

    Hello
    I am having an image displayed in the front panel. Now i want to select a portion of the image such that when i select that particular portion in the front panel , the result is displayed. Is this possible?
    AT present what i have done is, i take a subset from the image 2D array. But here i always have to enter the index and length by trial and error to locate the exact position. Is there a possibility to automatically detect the index and length when i select that portion in the original image???
    Thankyou
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************

    Hello Mike
    Thankyou very much for you example. This was what i meant. I have modified ur VI to what i need. But still am having a difference. When i click a particular point in the original image, iam getting the result image at a distance away from where i click on original image. I tried to subtract the original pic size from both but still not wrkin. any idea?
    Thnx
    Message Edited by Nghtcrwlr on 02-12-2009 05:54 AM
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Test 1.vi ‏31 KB

  • Selecting GeoRaster portions using SQL

    Hi,
    I am interested in selecting a portion of an image stored in the GeoRaster format inside Oracle. After looking at the documentation, I can see there is something useful in the oracle.spatial.georaster.image.GeoRasterImage - in particular the method:
    public RenderedImage getRasterImage(int pyramidLevel,JGeometry window)
    However looking at the supplied code sample in the API:
    //reading a GeoRaster object from database based on a query
    ResultSet rs = statement.executeQuery("SELECT a.georaster FROM georaster_table a where a.georaster.rasterdatatable='RDT' and a.georaster.rasterid=1");
    STRUCT geor = (oracle.sql.STRUCT) rs.getObject(1);
    //construct a JGeoRaster object
    JGeoRaster geoRaster = new JGeoRaster(geor);
    //get GeoRasterImage instance
    GeoRasterImage geoRasterImage=geoRaster.getGeoRasterImageObject();
    //fetch a subset of GeoRaster object as a Java image
    RenderedImage image=geoRasterImage.getRasterImage(0,0,0,100,100);
    it can be seen that the code to get the resultset uses the unique raster ID to get the initial object, then later in the code the sub-image is retrieved using the pyramid level and coordinates desired.
    But my question is this: getting the ResultSet in this manner requires the rasterid to be known ahead of time, which negates the whole reason/ability to select a sub-image based on coordinates/bounding box.
    How do I do a SELECT statement using a bounding box and pyramid level?
    Hopefully that makes sense
    Thanks
    MH

    Thanks, that advice has gone a long way. This worked well, and I managed to retrieve a blob for the bounding box I provided, and know that there is data there (I wrote the binary directly to disk and it had an appropriate file size).
    Now I'm trying to write the blob to a proper image file using this code:
    ImageInputStream blobStream = ImageIO.createImageInputStream(img_blob.getBinaryStream());
    BufferedImage img = ImageIO.read(blobStream);
    String fileName = "image_chip_00.tif";
    FileOutputStream out = new FileOutputStream(fileName);
    TIFFEncodeParam encodeParam = new TIFFEncodeParam();
    encodeParam.setCompression(TIFFEncodeParam.COMPRESSION_NONE);
    ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, encodeParam);
    encoder.encode(img);
    Unfortunately it comes back with a NullPointerException for the last line of code, i.e. the "img" object is null. For some reason it has not been filled with the blob data (Note that I know the blob is being retrieved and contains data). This blob originates from a stored procedure I wrote using the getRasterSubset mentioned earlier.
    Any ideas why the code may not be working?
    On a similar but different approach, does the SDO_GEOR.subset function have a Java API equivalent? For this function, is the "inGeoraster IN SDO_GEORASTER" listed in the spec simply a georaster column name? It sounds like SDO_GEOR.subset is very similar to SDO_GEOR.getRasterSubset except that it returns a georaster object instead of a blob (with no metadata), respectively.
    Thanks,
    MH

  • Captivate 5 - Audio Editing - Unable to Select a Portion of the Audio

    I need to edit the audio on each slide - specifically cut out long pauses - but I'm unable to select a portion of the audio. I can right click and Select All but that's not what I need.
    Any ideas what's wrong?

    Double click the audio waveform in the slide to open the Slide Audio dialog.  You should be on the Edit tab.  Select a section of dead space in the waveform and hit Delete.

  • How can I print just a select/highlighted portion of a webpage/email? FF prints EVERYTHING on each page, wasting ink.

    I switched form IE to FF. In IE, I could select text (or photos) and print just the portion of web pages and emails that I wanted, thus saving paper and ink. I have not been able to do that with FF. I have to print all of each page, so text, ads, and whatever other extraneous material prints. What a waste! Is there any way to select and print just what I need using FireFox? Currently I have to run both IE and FF to handle my printing and documentation needs. Thank you!

    Still happens with Firefox 12. I wish they'd just fix it, the way it used to be in Firefox 10, without the complicated workaround suggested above.

  • Preview - can't select a portion of created PDF

    Hi All,
    I'm not new the support community (have been able to resolve many an issue by searching), but this is the first time I'm posting.
    So, I've created a document via Pages and then saved it as PDF (using the print dialog box).  It's a form I use for work.  The form works mostly like a charm, even check boxes, etc.  However, there are three rows of text I have on the second page that I cannot highlight for the life of me.  The problem is that those are the three lines in which I (of course) need to be able to highlight text.
    The relevant part of the form is set up as follows (with [ ] denoting a check box):
    Intro Text (w/12 pt space after paragraph)
    [ ] Text 1     (tabbed space)     Option 1 / Option 2 / Option 3 (etc.)
    [ ] Text 2     (tabbed space)     Option 1 / Option 2 / Option 3 (etc.)
    [ ] Text 3     (tabbed space)     Option 1 / Option 2 / Option 3 (etc.)
    [ ] Text 4     (tabbed space)     Option 1 / Option 2 / Option 3 (etc.)
    [ ] Text 5     (tabbed space)     Option 1 / Option 2 / Option 3
    (lots of tabbed space)             Option 4 / Option 6 (etc.
    (space)
    Other text
    The bottom two rows (rows 4 & 5) in that list consisting of Text 1-5 can be highlighted just fine - I can highlight any portion, even individual letters.  The Intro Text and the text following the list can also be highlighted normally.  Even the parts that read "Text 1/2/3" can be highlighted, but I can't highlight the individual options in lines 1-3.  The only time that will highlight is if I highlight everything top to bottom, and only after I get past the paragraph starting with Line 5, Option 4.  And in that case it highlights everything, not individual options.
    I've posted a couple of screenshots below to help a bit.  Anyone has any input?  I can't make it work at all.  I edited and re-edited the original Pages doc a million times.  I can't figure things out on the Preview side of it either.  Please help!
    For reference:
    OS is Mavericks with all new relevant updates.
    Screenshots:
    Example of cannot highlight in row 1-3:
    Example of all rows highlighted:
    This is what I need to do in each individual row (right now only works for rows 4 & 5):

    You can only edit an entire graphic, not parts. In addition, you can not do the edit in Reader. In both of the cases you describe, you should be able to select the image to edit. The process you are using sounds like a graphic copy (at the screen resolution) which is far from an optimal process for getting the graphics. You can save all graphics to the hard drive and edit those, retaining all of the resolution of the original.
    In terms of the two cases, it sounds like the second shop may have set security to not allow copying of the graphic screen.

  • How do i select a portion of a document to print

    how do i print only a portion of a document that I have highlighted?

    InDesign can print a selection of pages (set a range in the print dialog) , not not parts of pages.
    That said, you might find this helpful: http://indesignsecrets.com/free-layout-zones-add-on-is-incredible-productivity-tool.php

  • How to select unused portions of my clips

    I shot a song/dance show during two different performances and have edited the best parts of both together.  Now I'm wondering if it's possible to select only the unused portions of each performance — not to delete, as others have posted about — but to actually use, for outtakes, or to create a complete video that won't be seen on the DVD I create.
    Is this possible?

    When you drag clips or parts of clips from an Event to a Project, an orange coloured line is placed along the base of the clip in the Event for the parts selected. So, all the portions of clips (or full clips) that don't have the orange line will be the pieces that you've not used in the Project. So, the unused bits are easily recognizable.
    You can now drag the unused portions to a new Project and then burn a separate DVD using iDVD. Or simply drag interesting segments from the Event to your original Project and use these at the end as out-takes. (NOTE: See CORRECTION below).
    Note that the unused segments may be easier to identify and select if you drag the Event thumbnail slider to the far left position, so that each thumbnail represents half a second of video. The slider is positioned at the base of the Events Library on the far right. There is a similarly positioned slider for Projects.
    Note also that when you trim or extend clips in the Project timeline, the orange line on the Event clip is shortened or lengthened accordingly, to match your adjusted selection. So, the unmarked segments in the Event are still a valid representation of your unused media.
    John
    CORRECTION:
    I just remembered that when opening a new project, you will not see the orange lines, as they only appear when the original project is open. To overcome this, duplicate the original project (File>Duplicate Project when in Project Library view) then add the unused media to the end of that project. Now delete all the clips or part clips used in the original project. This will leave you with just the earlier "unused" media in the duplicate project. Sorry about any confusion!
    Message was edited by: John Cogdell - added CORRECTION paragraph.

  • Selecting What Portion of a Clip Plays in Menu

    Old iDVD had this feature - I can't find it in '08 - I drop a clip into the background and it shows the very beginning - how can I assign it to play a more relevant portion of the clip?

    This is from iDVD Help:
    _Setting where a background movie begins and ends_
    When you use your own video as a menu’s background, you can use the entire video (up to 15 minutes), or part of it. To use part of it, you specify where you want it to begin and end in the Menu Info window.
    To specify the portion of video you want to show:
    Make sure the menu that uses the background video you want to adjust is showing in the iDVD window.
    With your pointer over the menu (and with no buttons or text objects selected), press Command-I to open the Menu Info window.
    Click the small triangle above the Loop Duration slider. (You see the triangle only when custom video is in the background well.)
    The slider control becomes the Background Movie Start/End control, and the slider is split in half.
    Move the left half of the slider, which plays the movie in the iDVD window, until you see the frame where you want the background video to start.
    Move the right half of the slider until you see the frame where you want the background video to end.
    Click the triangle again to return to the Loop Duration slider.
    I hope this helps.

  • In the "View"-- "Page Source" window: why can't I select a portion of a URL like I used to in previous versions? If I try, the source text behaves as an active hyperlink instead. This makes copying and editing HTML a pain!

    In want to copy a portion of a URL from the "View" --> "Page Source" window and paste it in my favorite text editor. This used to be a simple action with my mouse (mark portion with left mouse button, dump copy into editor window with middle mouse button). In Firefox 3.6.9, it is not plain text in the "Page Source" window but active hyperlinks (cursor shape changes) and takes me to the website of that URL, which I don't want. How can I get the original behavior (plain text page source) back?

    The code taht you have shown is not the template, it is a document that has been created from a template and renamed with a dwt extension.
    If you load the document into DW then go to menu item Modify->Templates->Detach from Template and save the file, you will have your original template called index.dwt and located in the Templates subdirectory.

  • Where is the tool to select a portion of an image to crop?

    I am new to PS cc 2014.  Where is the tool to select a potion of an image to crop?

    You'll find the Crop Tool on the Toolbar.  It might be behind the Slice or Perspective Crop tool.  
    Photoshop Help | Crop and straighten photos
    A small triangle on the tool icons denotes that other tools are located below.
    Nancy O.

  • Selecting a portion of the movie to darken using a continuous clip

    I have a section of the video that I need to darken. But if I select that section and click inspector to darken it, it makes the whole video darken. Then when I split the clip and darken that section it works…but as soon as I join the clip it reverts back to the original brightness. I am preparing this movie for an art exhibit, and need help a.s.a.p.! Any ideas?

    Hello Mike
    Thankyou very much for you example. This was what i meant. I have modified ur VI to what i need. But still am having a difference. When i click a particular point in the original image, iam getting the result image at a distance away from where i click on original image. I tried to subtract the original pic size from both but still not wrkin. any idea?
    Thnx
    Message Edited by Nghtcrwlr on 02-12-2009 05:54 AM
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Test 1.vi ‏31 KB

Maybe you are looking for

  • Can I define a SQL Server View to Oracle data?

    So I have a subset of data whose source of truth resides in an Oracle Database. Can I define a SQL Server View to retrieve this subset of data and make it available on the SQL Server side for say Reporting and SSRS? I think I also saw where they tend

  • Single table in Business model

    Hello, Is it possible to have only one table in the business model. If I try to add just one table into my business model, I receive the following error during consistency check. I could find no help in documentation. BUSINESS MODEL test: [nQSError:

  • Iphone4s can't receive push notifications of the third party apps, help?

    I got a iphone4s just for a month, and at first it can get all push notifications of mail, massenger, facebook, etc, but now it can only get push notifications of mail. And I have turned on push notification of these apps. Some one has the same quest

  • Problems displaying embedded Visio in Pages 4.1

    Hi all I just updated my Pages to 4.1 and immediately I'm having problems viewing visio diagrams in a .doc file. They show up as blank or some background coloring. Prior to the update, the visio diagrams were displayed OK. Please help.

  • HT1539 how do we not download extras when downloading a movie?

    When downloading certain movies that come with extras it seems to take longer and several attempts to download the extras. Is there a way to not have these down Load?