Add line as Component JPanel

hai,
I need to add a line as a Component to a JPanel
and the line shd listen to mouse events like
     mouseDrag : line move etc.
can anyone help?
anu

Run this sample, 2 lines that can be dragged.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Lines extends JFrame
     JPanel  pan  = new JPanel();
public Lines()
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,640,440);
     getContentPane().add(pan,BorderLayout.CENTER);
     pan.setLayout(null);
     myLine p1 = new myLine();
     p1.setBounds(20,20,400,3);
     p1.setBackground(Color.red);
     pan.add(p1);
     myLine p2 = new myLine();
     p2.setBounds(110,10,2,300);
     p2.setBackground(Color.blue);
     pan.add(p2);
     setVisible(true);
public class myLine extends JComponent
       int mx;
     int my;
public myLine()
     addMouseListener(new MouseAdapter()     
     {     public void mousePressed(MouseEvent m)
               mx = m.getX();
               my = m.getY();
     addMouseMotionListener(new MouseMotionAdapter()          
     {     public void mouseDragged(MouseEvent m)
               int x = getX() + m.getX() - mx;
               int y = getY() + m.getY() - my;
               setLocation(x,y);
public void paint(Graphics g)
     g.setColor(getBackground());
     g.fillRect(0,0,getWidth(),getHeight());
public static void main (String[] args) 
     new Lines();
}Noah

Similar Messages

  • Howto: Display text in the border line of the JPanel

    I create a JPanel and set it's border, later i add a textField at the border line of the JPanel, but when the words i type in, the line of border still at the center of the textField. Pls Help

    try this:
    import javax.swing.border.*;
    TitledBorder myBorder = new TitledBorder(" my Title ");
    myPanel.setBorder(myBorder);
    null

  • How to add line series dynamically to a line chart in flex?

    hi..i need to add line series dynamically to a line chart..depending on an array..the application is this..i have an array which stores the details of the users connected to an fmi server..the chart should display the bandwidth of each client..so the users should be added and removed from the chart dynamically...

    Hi
    1.I am giving you solution for dynamically adding values to the dropdown
    public void addValue( )  //Method Name in Component controller
        //@@begin addValue()
              IWDNodeInfo nodeinfo = wdContext.nodeNodeTestData().getNodeInfo();// Node should be map to the view's Node
              IWDAttributeInfo att = nodeinfo.getAttribute("VechileTypes");// Attribute by which dropdown in bound//
              IModifiableSimpleValueSet svSet = att.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
              svSet.put(wdContext.currentNodeTestDataElement().getInpAtt(),wdContext.currentNodeTestDataElement().getInpAtt());
        //@@end
    2.   wdThis.wdGetLangCompController().addValue(); // call this method in the point where u want to add values to the dropdown.

  • Add the same component in 2 different tabs

    I am trying to add the same component in two different tabs in a tabbed pane. When I add it (programaticaly) the first instance disappears. Is this at all possible. I dont want to clone the component first and then add it.
    Thank you

    In my appllication I have a tab (call it main tab) that includes many components, like a textfield and texteditorpane that form a command line tool, a list of connected clients (names) and several other components in the same tab. Now the user, can issue a command from the command line to open any component in a new tab, for example he might want to open the clients list in a separate tab, while still having an instance of the clients list in the main tab.
    Also when something is updated (for example a new name is added in the list) I want both instances to be updated at the same time (since there is actually one Jlist object there shouldn't be any additional code to do that).
    So far, when i am opening a new tab holding a component from the command line (the one i made), the same component disappears from the main tab.
    I ll try what was mentioned above.
    Edited by: FreshPrince1 on Apr 12, 2010 6:50 AM

  • Urjent-how to add line items in tcode-FBL3N

    Hi Experts,
      How to add line items customer, customer name,  vendor and vendor name in FBL3N.
    Thanks in advance.
    mahe
    Moderator message - Please do not use words like "urjent". Please ask a specific question. Please search the forum. This question has been asked and answered before. Post locked
    Edited by: Rob Burbank on Apr 29, 2009 11:27 AM
    Edited by: Rob Burbank on Apr 29, 2009 11:28 AM

    Hi,
    Check the BTE's:
    00001020     POST DOCUMENT:       Prior to final checks             SAMPLE_INTERFACE_00001020
    00001025     POST DOCUMENT:       Final checks completed       SAMPLE_INTERFACE_00001025
    00001030     POST DOCUMENT:       Posting of standard data     SAMPLE_INTERFACE_00001030
    00001050     POST DOCUMENT:       Accounting interface           SAMPLE_INTERFACE_00001050
    Thanks & Regards,
    Harish

  • Solution Import Failure Message: Cannot add a Root Component 'GUID' of type 29 because it is not in the target system

    Hi all,
    Please refer to the error:
    Root Components import: FAILURE
    [2015-04-10 17:04:48.126] Process: w3wp |Organization:0937f109-45df-e411-80cf-0050560100db |Thread:   43 |Category: Exception |User: ac011cf7-ad36-405b-91cf-2155ca15efb1 |Level: Error |ReqId: d3924c06-ad4b-4d5e-a204-70f8170016e1 | CrmException..ctor
     ilOffset = 0x30
    at CrmException..ctor(String formattedErrorMessage, Int32 errorCode, Object[] arguments)  ilOffset = 0x30
    at ImportRootComponentsHandler.GetSolutionRootsCollection(Boolean throwIfMissing, Boolean skipRibbonCustomization)  ilOffset = 0x209
    at ImportRootComponentsHandler.ImportItem()  ilOffset = 0x8
    at ImportHandler.Import()  ilOffset = 0x43
    at RootImportHandler.ImportAndUpdateProgress(ImportHandler ih)  ilOffset = 0x7
    at RootImportHandler.HandleNonMetadataHandlers(String[] ImportEntities, ImportHandler& ihForCurrentPath)  ilOffset = 0x33
    at RootImportHandler.RunImport(String[] ImportEntities)  ilOffset = 0x1D8
    at ImportXml.RunImport(String[] ImportEntities)  ilOffset = 0xE
    at ImportXml.RunImport()  ilOffset = 0x5BF
    at ImportXmlService.ImportSolutionSkipCapable(Boolean overwriteUnmanagedCustomizations, Boolean publishWorkflows, Byte[] customizationFile, Guid importJobId, Boolean convertToManaged, Boolean skipProductUpdateDependencies,
    ExecutionContext context)  ilOffset = 0x46
    at RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)  ilOffset = 0xFFFFFFFF
    at RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)  ilOffset = 0x25
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)  ilOffset = 0xCF
    at LogicalMethodInfo.Invoke(Object target, Object[] values)  ilOffset = 0x4F
    at InternalOperationPlugin.Execute(IServiceProvider serviceProvider)  ilOffset = 0x57
    at V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)  ilOffset = 0x200
    at VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)  ilOffset = 0x65
    at Pipeline.Execute(PipelineExecutionContext context)  ilOffset = 0x65
    at MessageProcessor.Execute(PipelineExecutionContext context)  ilOffset = 0x1C5
    at InternalMessageDispatcher.Execute(PipelineExecutionContext context)  ilOffset = 0xE4
    at ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode,
    Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
     ilOffset = 0x16E
    at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, UserAuth userAuth, Guid targetUserId,
    OrganizationContext context, Boolean returnResponse, Boolean checkAdminMode)  ilOffset = 0x1F1
    at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode)  ilOffset
    = 0x2D
    at OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode)  ilOffset = 0x26
    at InprocessServiceProxy.ExecuteCore(OrganizationRequest request)  ilOffset = 0x34
    at PlatformCommand.XrmExecuteInternal()  ilOffset = 0xF6
    at ImportSolutionCommand.Execute()  ilOffset = 0x20
    at DataSource.ImportSolution(Byte[] customizationFile, Boolean overwriteUnmanagedCustomizations, Boolean publishWorkflows, Guid importJobId, Boolean convertToManaged, Boolean skipProductUpdateDependencies, IOrganizationContext
    context)  ilOffset = 0x0
    at SolutionImportProcessPage.ImportSolution()  ilOffset = 0x123
    at SolutionImportProcessPage.ProcessRequestData()  ilOffset = 0x4A
    at SolutionImportProcessPage.ProcessAction(String action)  ilOffset = 0x92
    at AppUIPage.OnPreRender(EventArgs e)  ilOffset = 0xD
    at Control.PreRenderRecursiveInternal()  ilOffset = 0x54
    at Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  ilOffset = 0x6D3
    at Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  ilOffset = 0x3C
    at Page.ProcessRequest()  ilOffset = 0x14
    at Page.ProcessRequest(HttpContext context)  ilOffset = 0x33
    at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  ilOffset = 0x18D
    at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  ilOffset = 0x15
    at ApplicationStepManager.ResumeSteps(Exception error)  ilOffset = 0x10A
    at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)  ilOffset = 0x5C
    at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)  ilOffset = 0x16A
    at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)  ilOffset = 0x4B
    >Crm Exception: Message: Cannot add a Root Component 0ffbcde4-61c1-4355-aa89-aa1d7b2b8792 of type 29 because it is not in the target system., ErrorCode: -2147188705
    [2015-04-10 17:04:48.126] Process: w3wp |Organization:0937f109-45df-e411-80cf-0050560100db |Thread:   43 |Category: Platform.Sql |User: ac011cf7-ad36-405b-91cf-2155ca15efb1 |Level: Info |ReqId: d3924c06-ad4b-4d5e-a204-70f8170016e1 | BusinessProcessObject.ExecuteNonQuery
     ilOffset = 0x28
    I am getting this coming up in the error log when I attempt to import an unmanaged solution.
    After searching on google Type 29 refers to a workflow.
    I go into the source system and query the database by the GUID and discover that it is actually a Business Process Flow called 'Phone to Case Process'. 
    I do not have this process in my target system as I deleted it.
    Looks like this is one of the out of the box ones. I don't think we we have changed this one much.
    What does this mean and what should I be looking for??
    Anyway how do I remove this offending process from the unmanaged solution xml file and attempt to re-import it? 
    It doesn't look like I can generate the solution again without the offending workflow/process..

    I managed to resolve this issue after looking at this thread:
    https://social.microsoft.com/Forums/en-US/fddff17f-1cca-4d33-a666-60c08ad76b0c/crm-2011-import-failure?forum=crmdevelopment
    Just modify both solution and customizations xml by searching for the guid and removing the root component

  • EXIT to change / add line items during STO PO creation in T.Code ME21N

    Hi
    Can somebody suggest me a EXIT or a BADI  to change / add line items during STO PO creation in T.Code ME21N.
    The requirement is as below.
    When the user enters a material no ( which has a BOM created in CS01), and presses enter or saves the PO, i need to get the sub components of the BOM and populate them as the next line items.
    This is because the user needs to create the delivery with reference to the PO. In the delivery, the BOM material needs to be populated with all the sub components of the BOM.
    I tried to do it using EXIT_SAPMM06E_013 in which i am able to change / add the line items in the XEKPO and YEKPO internal tables. The entries are available in the internal table when the EXIT is executed.
    But when the PO is posted internally, the item is not changed/added.
    Thanks in advance.
    Guna.

    Hi,
    Try BADI "ME_PROCESS_PO_CUST".
    cheers,

  • RWIN to automatically add line items in FI document

    Hi all!
    I wish to know if is possible to automatically add line items in a FI document via RWIN and how.
    My final goal is the following:
    A user try to create an FI document with FB01 transaction.
    He/She insert the appropriate line items manually.
    He/She press the "Simulation" button
    In simulation screen there are user's line items, PLUS some more that are necessary in some circumstances.
    Is it possible to achieve this scenario?

    Hi Marinos,
    i think it's  possible via table <b>TRWPR</b> and an
    appropriate function module but it's hold for a modification by SAP.
    other possible solutions:
    - user exit ?
    - interface ( e.g. Intranet-appl. / excel)
      and posting via RFBIBL00 / BAPI
    regards Andreas

  • Automatically add line-items to Sales order

    Hello,
    Our client needs us to add line items to sales orders. The requirement is such that, when the users enter a material on a line item, they wish to see few more materials automatically added as new line items -- item category to be maintained as "Free" items. This appears similar to automatically getting BOM-sub-items for materials which have BOMs maintained. The client is not willing to maintain BOMs for materials in question. They instead have asked us to maintain sub-item materials in a Z-table and then fetch those to populate the subsequent line-items on the sales order.
    So far, we have tried to fiddle around with the XVBAK and XVBAP internal tables in sales exit (MV45AFZZ) and also tried to use BAPI within the same exit. Both methods do not work.
    Could you please guide us ? Thank you.
    Regards,

    Hi,
    I think you can try with product proposal(Item Proposal). T.Code:VA51.
    Using this one can create list of items to be proposed at the time sales order processing.
    Item proposal contains list of items with or without default quantities those were frequently ordered by the customer. You can create any no of items in an Item proposal.Like wise you can create any no.of item proposals.
    But,You can assign only one item proposal per customer in sales tab of the CMR.So that when ever you are creating order for that customer you can access those materials which are listed in an Item proposal completely or selectively,with or without default quantities.
    The items which are proposed from an Item proposal are always changeable.
    Item proposal makes sales order processing simple and fast.
    Only the thing here is it will not automatically explode like in case of BOM.You have to manually select those items from an item proposal.
    Regards,
    Revan
    Edited by: REVAN on Dec 23, 2008 10:55 AM

  • Automatically add line-items to sales orders

    Hello,
    Our client needs us to add line items to sales orders. The requirement is such that, when the users enter a material on a line item, they wish to see few more materials automatically added as new line items -- item category to be maintained as "Free" items. This appears similar to automatically getting BOM-sub-items for materials which have BOMs maintained. The client is not willing to maintain BOMs for materials in question. They instead have asked us to maintain sub-item materials in a Z-table and then fetch those to populate the subsequent line-items on the sales order.
    So far, we have tried to fiddle around with the XVBAK and XVBAP internal tables in sales exit (MV45AFZZ) and also tried to use BAPI within the same exit. Both methods do not work.
    Could you please guide us ? Thank you.
    Regards,

    Ist method:
    Maintain one Ztable with the fields of Material and sub materials.
    write BDC to create order,before entering the material  number check if material is existed in Ztable or not.
    If it exist take that material and added as a another line item.
    if not exist create like normal line item.
    2 nd method:
    Ask your MM functional consultant to maintain supression of materials concept.

  • Is there a way to add line numbers in the margin?

    Is there a way to automatically add line numbers in the margin of a document?

    Hi Brian,
    If you go with Peter's suggestion, there are some details that since I've got a minute here, I'll mention...
    Set your Line Spacing for the document text to "Exactly" before you begin adjusting your table, otherwise you will have registration problems.
    Your Table will have to be a Floating object. Otherwise you won't be able to slide it into the margin. And, speaking of the margin, stay out of the gray area with the numbers if you want to print them. The gray border around your document is the area that the printer driver says is non-printable.
    In the Table Inspector, set Columns to 1 and Rows to 20 or whatever you prefer for your document. Set the number of Header Rows to 0.
    To apply the numbering, use the Fill feature: Type 1 in the first cell, type 2 in the second cell. Select both cells. Grab the Fill Handle in the lower right corner of the selection and drag it down to add a series of numbers to the rest of the column. (Easier than typing.)
    Decide how you want to justify the numbering. The Text Inspector has both vertical and horizontal justification controls for this. Just select the entire table and make the settings.
    Set the cell height to match the text line spacing. You can get close with the table row height, and maybe closer with a minor line spacing adjustment. Don't expect perfection, but you can get pretty close.
    You probably don't want the cell borders to show, so with the entire table selected, go to the Graphic Inspector and set Stroke to None.
    Lastly, cause the table to appear on every page by doing: Format > Advanced > Move Object to Section Master.
    Regards,
    Jerry

  • I somehow managed to add lines on my master slide and can't get rid of them.  I now have a useless rectangle on the left half of many of my slides.  How do I remove this?

    I somehow managed to add lines on my master slide and can't get rid of them.  I now have a useless rectangle on the left half of many of my slides.  How do I remove this?

    Select the master slide,
    copy any objects you want to keep,
    Select all, (command A), and press delete key.
    Paste back the items to retain (Command V)

  • UDO type Document, Add lines

    Hi All,
    I have a problem with a User Defined Object of type Document/Document Lines.
    I have a custom form for the UDO. I can add new Documents with one or more Document Lines. These are stored in the database as expected, both Father table and Child table is updated. I can also update existing entries through the UDO, but I can NOT add new Document Lines to an existing Document.
    I can add the lines in the matrix of the form, but they are not written to the Child table when I press Update. There is no error messages or anything, the new lines are just not written.
    Any suggestions?
    Best regards
    Jesper Carstensen

    When you add a line to the matrix did you increase the size of the datasource as well?
    A sample of code to add line:
    dbMOR1.InsertRecord dbMOR1.Size
    dbMOR1.Offset = dbMOR1.Size - 1
    m_oMatrix.AddRow 1
    (dbMOR1 is the satasource of the child table that is bound to the matrix columns).

  • Project Server 2007: use cannot add lines to or recall timesheet

    I have a certain user that, for some reason, cannot use the Add Lines or Recall Timesheet function in Project Server 2007 SP3. The weird thing is, it works on another laptop, so it must be something related to the user's machine - but I'm baffled as to what
    the exact cause may be.
    There's no error what so ever - no Error On Page as is pretty common with these behaviors.
    Here's what I've tried so far:
    - Internet Explorer 8 version is supported
    - Deleted ActiveX controls, but these don't seem to be a prerequisite for Timesheets
    - IE Compatibility mode on/off
    I have no idea what else to check, and I want to make sure I've tackled everything before escalating this to SysOps for a browser/OS reinstall.

    Hi DMachiels,
    Have you tried to refresh your IE session deleting the cache (CTRL F5)?
    Also ensure that the PWA URL is include in the IE trusted sites (intranet and internet).
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • How to add line item to sales order item table?

    Kindly help me the with the below requirement .
    Add line item to sales order(va01) dynamically on click of button. The button is also custom created push button.
    In the above requirement I have added the pushbutton to va01 tcode. But when I click on that button I need to add line item to sales order item table.
    I tried a lot but I am not successful. If possible can u please help on this.
    Regards,
    Rachel

    Hi!
    It's quite easy even in the standard SAP to add a line item for a customer order, I don't think it worth to develop a new button for this.
    However if you wanted to add a line automatically, the you can do the following in the program MV45AFZZ, FORM USEREXIT_SAVE_DOCUMENT.
    You can use similar code, but with some modifications.
    DATA: lv_posnr.
    LOOP AT xvbap.
    MOVE xvbap-posnr TO lv_posnr.   "get the last posnr
    ENDLOOP.
    ADD 10 TO lv_posnr.
    MOVE 'XYZ' TO xvbap-matnr.   "enter your material number here
    MOVE lv_posnr TO xvbap-posnr.
    * fill additinal field data in XVBAP if necessary
    MOVE 'I' TO xvbap-updkz.                  "Insert line
    APPEND xvbap.
    Regards
    Tamá

Maybe you are looking for