Complete box? drawing lines

Hello,
I want to allow a user to draw lines on a canvas and then know when all the points make up an area that is a box.
How can this be done? What checks would I need to do everytime a line is drawn?

A few fixes:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class ClickHere extends JPanel {
    private GeneralPath path;
    private int startX=-1, startY=-1;
    private Color foreground = Color.RED;
    public ClickHere() {
        addMouseListener(new MouseAdapter(){
            public void mousePressed(MouseEvent evt) {
                int x = ((evt.getX()+5)/10)*10;
                int y = ((evt.getY()+5)/10)*10;
                if (path == null) {
                    path = new GeneralPath();
                    path.moveTo(x, y);
                    startX = x;
                    startY = y;
                } else if (x==startX && y == startY) {
                    path.closePath();
                    foreground = Color.GREEN;
                    removeMouseListener(this);
                } else
                    path.lineTo(x, y);
                repaint();
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (path != null) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setColor(foreground);
            g2.drawRect(startX-2, startY-2, 5, 5);
            g2.draw(path);
    public static void main(String[] args) {
        JFrame f = new JFrame("ClickHere");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new ClickHere());
        f.setSize(450, 400);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}

Similar Messages

  • How to draw a box before Line Item in the Main Window  In SapScript

    Hi guys,
    I am trying to draw a box before Line items to be printed but it overwriting the Line Item can anyone help me in this.
    Thanks,
    Ramesh

    Hi ramesh,
    check this:
    /E   TOP
       plant,,status,,GROUP,,Profit,,Min.Size,,Max.Size
    /:   BOX FRAME 10 TW
    /:   BOX YPOS 2 CH HEIGHT 0 CM FRAME 10 TW
    /*   BOX XPOS 15 CH WIDTH 0 CM FRAME 10 TW
    /*   BOX XPOS 28 CH WIDTH 0 CM FRAME 10 TW
    /*   BOX XPOS 35 CH WIDTH 0 CM FRAME 10 TW
    /*   BOX XPOS 42 CH WIDTH 0 CM FRAME 10 TW
    /*   BOX XPOS 55 CH WIDTH 0 CM FRAME 10 TW
    /E   NEW
       &IT_SCRIPT-pstat(C)&,,&IT_SCRIPT-werks(C)&,,
    =    &IT_SCRIPT-EKGRP(C)&,,&IT_SCRIPT-PRCTR(C)&,,
    =    &IT_SCRIPT-MINLS(C)&,,&IT_SCRIPT-MAXLS(C)&
    /:   BOX FRAME 10 TW
    /:   BOX YPOS 2 CH HEIGHT 0 CM FRAME 10 TW
    /:   BOX XPOS 15 CH WIDTH 0 CM FRAME 10 TW
    /:   BOX XPOS 28 CH WIDTH 0 CM FRAME 10 TW
    /:   BOX XPOS 35 CH WIDTH 0 CM FRAME 10 TW
    /:   BOX XPOS 42 CH WIDTH 0 CM FRAME 10 TW
    /:   BOX XPOS 55 CH WIDTH 0 CM FRAME 10 TW
    the corresponding code in abap editor:
    CALL FUNCTION 'OPEN_FORM'
      EXPORTING
       APPLICATION                       = 'TX'
       ARCHIVE_INDEX                     =
       ARCHIVE_PARAMS                    =
       DEVICE                            = 'PRINTER'
       DIALOG                            = 'X'
        FORM                              = 'ZFINAL_13688'
        LANGUAGE                          = SY-LANGU
      EXCEPTIONS
        CANCELED                          = 1
        DEVICE                            = 2
        FORM                              = 3
        OPTIONS                           = 4
        UNCLOSED                          = 5
        MAIL_OPTIONS                      = 6
        ARCHIVE_ERROR                     = 7
        INVALID_FAX_NUMBER                = 8
        MORE_PARAMS_NEEDED_IN_BATCH       = 9
        SPOOL_ERROR                       = 10
        CODEPAGE                          = 11
        OTHERS                            = 12
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'WRITE_FORM'
                        EXPORTING
                          ELEMENT                        = 'TOP'
                        FUNCTION                       = 'SET'
                          TYPE                           = 'TOP'
                          WINDOW                         = 'MAIN'
                        EXCEPTIONS
                          ELEMENT                        = 1
                          FUNCTION                       = 2
                          TYPE                           = 3
                          UNOPENED                       = 4
                          UNSTARTED                      = 5
                          WINDOW                         = 6
                          BAD_PAGEFORMAT_FOR_PRINT       = 7
                          SPOOL_ERROR                    = 8
                          CODEPAGE                       = 9
                          OTHERS                         = 10
                       IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                       ENDIF.
    LOOP AT IT_SCRIPT.
      CALL FUNCTION 'WRITE_FORM'
       EXPORTING
         ELEMENT                        = 'NEW'
        FUNCTION                       = 'SET'
         TYPE                           = 'BODY'
         WINDOW                         = 'MAIN'
       EXCEPTIONS
         ELEMENT                        = 1
         FUNCTION                       = 2
         TYPE                           = 3
         UNOPENED                       = 4
         UNSTARTED                      = 5
         WINDOW                         = 6
         BAD_PAGEFORMAT_FOR_PRINT       = 7
         SPOOL_ERROR                    = 8
         CODEPAGE                       = 9
         OTHERS                         = 10
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ENDLOOP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
      RESULT                         =
      RDI_RESULT                     =
    TABLES
      OTFDATA                        =
    EXCEPTIONS
       UNOPENED                       = 1
       BAD_PAGEFORMAT_FOR_PRINT       = 2
       SEND_ERROR                     = 3
       SPOOL_ERROR                    = 4
       CODEPAGE                       = 5
       OTHERS                         = 6
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    regards,
    keerthi.

  • Drawing tables without boxes and lines in XI

    Post Author: geeeeee
    CA Forum: Crystal Reports
    Hi I'm trying to figure a way to draw tables in XI (it seems like a pretty simple task) but I can't find how to draw a table without hand drawing lines and boxes. Any ideas? Thanks

    Hi,
    Unfortunatelly drawing a frame for table is not so straightforward. To draw a frame around the columns and table itself you need to create a window (on top of window where you display your table) placing it at column position and checking Lines width in Output Options tab for this window. This will produce a fake column frame. See [this example|http://img294.imageshack.us/my.php?image=tableq.png].
    For rows you could do similar: check what is the heihgt of row in the table and draw respective windows as rows. This one, however will look a bit strange, but for columns it looks and works fine.
    Regards
    Marcin

  • CP5: connecting permanently text boxes by lines

    When I create several text boxes and want to connect them like a diagram with lines (see below): how should I draw the lines so that they would not loose the entry points of both related tex boxes when a text box is moved on the slide?
    With my first approach I could draw the boxes and lines, but they are completely independent from another. Any change would require a lot of additional work to keep the lines intact.

    Hello again,
    I did not understand your first question well, did not know that you want to animate this, make it grow as you said. You really want an animation, but with ability to edit quite a lot. Do not see an easy solution immediately, sorry. Personally I would rather start doing this from the end slide, and work in Photoshop (using layers and the roundtripping) or creating the animations in Flash. Do you want to add effects too?
    Captivate was not really designed for creating graphical assets like you want now, although it has a lot improved since earlier versions. Please, feel free to introduce a feature request for this kind of drawing objects (dynamic connecting lines).
    Lilybiri

  • How to set delv. completed in 2nd line item which created in PO by default

    Dear guru,
    When creating 1st line item by default the 2nd line item has been created. I understand that the 2nd line item is free because no net price has been stated but free good check box in not ticket. Further more the 2nd line is grayed out including all tab in item details. Meaning we can't do any changes in this line item.
    User set delivery completed in 1st line item but couldn't set in 2nd line item. This caused to this PO show still pending for delievery when run the report. How we can set this 2nd line item has delivery completed eventhough GR haven't done fully.
    rgds,
    nantha

    Dear Mahesh,
    The 2nd line is free good that assign with 1st line item. This has been set in purchasing info record under condition view. Thus when I create PO for 1st line item, system created 2nd line item as auto default. The issue here is the 2nd line item & all the field that in item details in PO become grayed out eventhough I go to ME22N. I cant do any changes on 2nd line item. I believe there would be some control maintain for free good. Please advice. Thank you.
    rgds,
    nantha

  • How to draw line on SAP form

    Hi everyone,
    Who have a good way to draw lines on SAP form?
    I created a Wizard form, and use Rectangle (Height=0) as the two lines between title and bottom button, but I met a problem, when show another form which cover the line, after close this form, some part of lines disappear, I have tried using SAP form refresh, it still can not restore showing line completely, who have good way to workaround the problem or give me another way to draw line.
    Thanks in advance!
    Kathy

    The only way I found to get a form looking really close to a standard B1 Wizard form is to use bitmaps.  I use 3 - one each for the top, bottom and left hand side.  The bitmaps include the line drawing and appropriate pictures/background colours.  I normally define these in the XML used to create the form as in the following example:-
    <item uid="PTOP" type="117" left="0" width="566" top="0" height="80" visible="1" enabled="1" from_pane="0" to_pane="0">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ_TOP2.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    <item uid="PBOT" type="117" left="0" width="566" top="336" height="40" visible="1" enabled="1" from_pane="0" to_pane="0">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ_BOT.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    <item uid="PLEFT" type="117" left="0" width="100" top="0" height="336" visible="1" enabled="1" from_pane="1" to_pane="1">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ9.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    John.

  • SAPScript box drawing

    Hi Guys,
    I'm facing difficulties on drawing a box with records in SAPScript. Im using below for box drawing:
    1. Draw main box
    /: BOX WIDTH 280 MM HEIGHT 130 MM FRAME 10 TW 
    2. Draw vertical line to separate each different COLUMN
    /: BOX XPOS 15 CH WIDTH 0 CH HEIGHT 130 MM FRAME 10 TW
    3. Draw <b>horizontal line</b> to separate each different RECORD
    /: BOX YPOS 4   CH WIDTH 280 MM HEIGHT 0 CH FRAME 10 TW
    Problems:
    1.  For drawing <b>horizontal line</b> to seprate each record, basically i fix a static incremental counter for YPOS xxx CH.
    For eg:
    1st line -> /: BOX YPOS <b>4</b>   CH WIDTH 280 MM HEIGHT 0 CH FRAME 10 TW
    2nd line -> /: BOX YPOS<b> 6</b>   CH WIDTH 280 MM HEIGHT 0 CH FRAME 10 TW
    3rd line -> /: BOX YPOS <b>8</b>   CH WIDTH 280 MM HEIGHT 0 CH FRAME 10 TW
    ... and so on, until the end of the box
    The output LINE for first few records still ok, but for the rest it is <b>overlapping</b> with the records.
    ---> Please comment the right way to overcome above.
    2. The code for drawing horizontal line is a lot, is there a better to perform the drawing?
    > Please comment
    Thanks in advance.

    Hi,
    My problem solved by using LN as below:
    :/ BOX YPOS 4 <b>LN</b> WIDTH 280 MM HEIGHT 0 CH FRAME 10 TW
    But right now, im using command SIZE to draw a box for me automatically by following the actual window size. I did that with no problem.
    But im facing problem when im drawing Vertical line(column separator)within the box. Im intend to draw a line <b>without</b> specific the height for <b>Vertical</b> line(because my 2nd page's height is larger than 1st page and thus i do not want to harcode the height). Below is my code:
    /:SIZE WINDOW                      -->Draw main box
    /:BOX FRAME 10 TW                  -->Draw main box
    /:BOX XPOS 15  CH FRAME 10 TW      --> Draw vertical line
    The result returned with problem,  there are 2 vertical line being draw out. 1st line is draw at position 15 ch as instructed by the command, but there is <b>2nd line draw out of my main box</b> on right, this is not expected.
    Please comment on how should i fix the code.
    Thanks in advance.

  • SmartForms - draw line in template

    Hi!
      I am new to SF, so have a question on drawing line in a template. I use template as the data is only printed out once and is static. I have many columns in my template and I would like to draw lines on the columns so that it is tidy & looks nicer.
      I double click the template & in the "output options" tab, I checked the check box "line with..", but error prompt out to stop me, saying "Boxes/Shadings are not allowed within a table".
      Does anyone know how can I draw lines in a template?
      Kindly advise.
    best regards,
    Ginnie

    Hi,
             Click on the template under the template tab, and then click on the select pattern just under the template heading , there you use lines.
    regards,
    Santosh Thorat
    Edited by: santosh thorat on Dec 26, 2007 10:09 AM

  • Need to draw line after the 2nd line item(Smart Forms)

    Dear Friends,
    I need to draw horizontal line after the 2nd line item  and 3rd line item in smart forms.How can i achive this.
    Plz help.
    Edited by: farook shaik on May 19, 2009 8:19 AM

    This is what you need to do:
    1> In the tables->details section define two line types LT1 and LT2.
    2> Come back to tables section pressing the table painter button.
    3> Select a line type for which you want to have an underline(say LT2).
         a] If the anchor cursor does not come click the draw lines and columns button( the pencil icon nutton)
         b] select the line type ( it will become black after selection. Press and hold down ctrl to select
             multiple cells.
         c] after selection click the lower 'frame button' ( which is right at the top of box and shading).
    4> Now goto data section where you have given your internal table name and work area.
         a] in the sort criteria put your field POSNR and check the Event on Sort end chk box.
         b] you will see an extra node under the main area of the table.
         c] Create a table line with the line type LT2 in the node.
         d]Also in the Main area add another table line with LT1 as the line type.
    5> If POSNR remains unchnged LT1 will be triggered.
    6> if Posnr changes then LT2 will be triggered with the underline.
    This will suffice your requirement.

  • Why have some apps on my Ipad turned into a grey box with lines in it?

    3 apps on my ipad have turned from icons into grey boxes with lines in them. When I click on them, they try updating but it doesn't complete. What's going on here? Is this some kind of virus?

    Not a virus. More like a glitch. When mine did that all I needed to do was to open the apps and the icons reset.
    If you won't lose any game progress or the such, you could try to delete and then redownload the apps.
    If you're having issues downloading the apps, try to go into the settings, iTUnes and app store, sign out and then sign back in.
    The app store has been a bit wiggy lately. I've had some issues downloading apps or updates and it's not on my end, it's on Apple's end. Which, unfortunately, means there's not much a user can do but wait for Apple to fix it.

  • Invoice verification:-- complete atleast one line of ACCOUNTINGDATA

    Sap Gurus,
    During invoice verification an error is coming.... " complete atleast one line of accounting data for item 000003".
    In PO account assignment is cost center and item category is services.
    service line item is having 3 parts.
    1st and 3rd  is linked with cost center 25020 and 3rd one to 25030. 2nd is linked with cost center 25030.

    Hi Chintan
    thanks for the Prompt reply. But where can we see the Account assignment from. Is it referring to the account assignment field in PO. The same Account assignment (Cost Center) has been entered in the PO line item as well.
    Thanks
    Nitin

  • Text Boxes and Lines on Full Screen Images?

    In iBooks Author I'm trying to create images with text boxes and lines overlayed on top of the images (I don't like the interactive image widget, I want just text with no gray box and a single line of text, no need for title and description, also don't need the zoom capability on each label).  I can do this fine in a basic, two column layout but when I tap on an image within a figure to see it full screen on the iPad I want the text and lines to also come full screen.  Any ideas?  I seemed to have a solution by enabling placeholder text authoring but that's proven inconsistent.

    Sound like a 'group'.
    Whatever works
    Good luck
    Ken

  • "Always Use Selected Format" check box in line items report

    Hi Experts,
    I have an issue in ECC 6.0.
    From the transaction code FBL1N (Vendor Line Items) I am trying to export the report to spreadsheet by selecting the option  List> Export>Spreadsheet  then I have selected "Always Use Selected Format" check box.  But if I execute the same report again I am not getting this option "Always Use Selected Format". Please let me how can we retrieve that option. Is there any possibility to get that option again either functionally or technically. I would like to know all the possible ways to get this option again.
    Please do the needful.

    Hello,
    In one my thread Mr. Frank has replied as follows. I believe he has solved this.
    Hope this may be really helpful.
    The problem with the spreadsheet download is at one point, users have selected their default file type.
    That said, SAPGUI is working as it should. (gui710)
    Question though is how do we reset the values so they get the ?Select Spreadsheet Format? popup again.
    The following steps should be performed :
    - Call transaction SE38, enter program SALV_BS_ADMIN_MAINTAIN, and press F8.
    - Follow the parameters below :
    - Select ?DELETE? on the Actions Group
    - Select ?DETAILED SELECTION? on the General Data :
    - On Client - your number
    - User : <user name>
    -Hit EXECUTE.
    -Press ENTER on the POPUP
    - If there is an entry in the report that will need to be deleted. Also, make sure that the entry you will delete (for the user) has a value of GUI_ALV_XML_VER on field ?Parameter? .
    - Select the line and hit the DELETE icon .
    - Press ?Y? to continue delete. Press ENTER on the popup.
    - Then EXIT all the way out of the program.
    NOTE : When you run program SALV_BS_ADMIN_MAINTAIN, make sure they are out of any program that they are using for download.
    Re: "Always Use Selected Format" check box in line items report
    Regards,
    Ravi
    Edited by: Ravi Sankar Venna on May 15, 2009 2:31 PM

  • Reducing PDF-size: automatic reduction of datapoints that are used to draw lines in a 2d-axis system within report

    Creating fancy pdf-files for costumers and other purposes is great. However, if the experimental data include many datapoints (>200000) a line-2d-graph ends up in a very big pdf-file. Especially when many pages need to be used.
    Explanation:
    When I use lines to show experimental data in 2d-plots the size of my PDF-file is directly influenced by the number of datapoints used. The more datapoints are used to draw lines within the graph, the bigger the exported PDF-files of the report are.
    It would be great to limit the number of points used to draw a line as it can be done with markers without using the curve transformation option. - Hence, e.g. plotting a line with the help of 200 datapoints is usually as good as showing the same line based on 200000 datapoints but the pdf-size is significantly reduced. You can imagine that when this would be done via the transformation option a long lasting script would be needed for each line to reduce the number of datapoints shown. Hence, the plotting within the report and the actualisation of data would need very long.
     

    Since a while DIAdem optimizes the size of exported PDF-files in a related way as it is suggested here. In principle the PDF-file is exported in a very high resolution, so you can display it in a reader with a very high zoom value (e. g. 6000 %) to look into details of your data. If you have a huge dataset, this could lead in fact to a bigger file size, if data points could be displayed because the high PDF-resolution. But in general, DIAdem only saves information in a PDF-file which is really necessary - but with a high resolution.

  • Why am I getting black boxes and lines in Facebook chat area?

    I just installed the latest version of Firefox as well as the latest version of my graphics card drivers, and Adobe Flash Player. When I open Facebook, I get black boxes and lines all over the left side of the screen where my chat contacts are. I am wondering why this is happening and if there is a current fix to it, as it is rather annoying. When I hover my mouse next to or over the black boxes and lines, they move and continue to pop up elsewhere but only on the friends/chat area.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

Maybe you are looking for

  • Report Painter - Balance Sheet Accumulated Balance not shown

    Dear Fellow SAP Gurus, I'm trying to create a Balance Sheet Report using Report Painter. The Library that I'm using is 8A2, GLCPT Table and 8A Ledger. I have defined the General Data Selection, Characteristics, Key Figures and assigned the report to

  • My left earpod is not working

    i tried to scrape it but its not working still and i saw that a wire was broke. What should i do? Help me someone!

  • How to create rewrite rule to accept only mail pass from antivirus server

    I want to set JES messaging 6.0 to accept only mail that scaned from antivirus server. If clients send direct to messaging server it will forward that mail to antivirus server. After mail was scaned it is sent to messaging server and messaging server

  • Failed to create task or type source2wsdd

    Hi, I am trying to run the sample code for webservice that i got from the net.I am new to webservice.When i try to run the build file,i got the below given error. ***Buildfile: C:\WS\test\tutorial\sample10\build.xml**z* ***clean:*** ***[delete] Delet

  • Wlc 5508 Guest logon page

    Where do you turn this option off? i have looked under security and did not see any thing.  Thanks