Creating a drawing (CAD) program in Java

I'm in the planning stages of creating a drawing/drafting program in Java, and I'm fairly new to Swing, so I need some guidance.
For a drafting program, I will need to be able to draw all kinds of objects using lines, curves, etc, connected in various ways. One thing I could do is extend JComponent and override the paint() method, and have it put up all the various objects as it repaints. The problem with this is that if a user clicks on an object, how will I detect which object he clicked on? I'll get mouse coordinates, but then how do I go from that to knowing that he clicked on a certain curve, etc?
The alternative is to not extend JComponent, but rather to make each of the individual objects on the screen its own component and then lay them out using absolute positioning. Then I'll get mouse events as the user clicks on things. Is this a better way to do it? And if so, I guess I'll still need to create individual components that represent lines, arcs, curves, etc?
Swing has so many features that it's hard for a beginning to get started into it. Thanks for any tips.

Personally I wouldn't work with Swing for this functionality,
but I would rather work with java 2D instead.
Swing contains to much overhead for the kind of application you plan to develop.
Look for the java.awt.Shape interface and to the java.awt.geom.* implementations of such shapes.
It contains already most of the functionality required for painting and hit-detection of a shape on the
screen.
kind regards,

Similar Messages

  • Can i create an exetutable (.exe) program with java???????

    I would like to learn how i can create an exetutable (.exe) program with java.
    Is there any additional package which i should download or buy it?
    Also i would like to write files into CD's direct from my application.
    Is there any library which i must download or buy?
    Thanks!

    check out the free open source GNU gcj native compiler for Java to see if it will do what you want.
    http://gcc.gnu.org/java/
    for writing data files you could use java.io.BufferedWriter. For sound files, look in the javax.sound package

  • Creating a basic loop program in java

    I'm working on a program for school. The program asks the user for an in put number between 1-20. The program then outputs a square made of asterisks that corresponds with the number entered. for example :
    2 =
    3 =
    This is what I have so far, but I don't know how to create a straight line of asterisks for an input number of 3 or higher
    public class square {
    * @param args the command line arguments
    public static void main(String[] args)
    Scanner input = new Scanner( System.in);
    int number = 0;
    System.out.print( "Enter a number between 1 and 20\t" );
    number = input.nextInt();
    if (number <1)
    System.out.printf( " Number must be greater than 0 ");
    if (number >20)
    System.out.printf(" Number must not be greater than 20");
    if (number ==1)
    System.out.printf("*");
    if (number ==2)
    System.out.println ("**\n**");
    if (number >= 3)
    Any help would be greatly appreciated!
    Edited by: Methodx on Jan 22, 2009 9:24 PM

    You would need two for loops .
    In the inner loop , print either an asterix or a space based on wheter the point ur considering is on the edge of the square or inside the square.
    In the outer loop , skip to the next line.
    (0,0)    (0,1)    (0,2)     (0,3)
    (1,0)    (1,1)    (1,2)     (1,3)
    (2,0)    (2,1)    (2,2)     (2,3)
    (3,0)    (3,1)    (3,2)     (3,3)You can work out the condition to be used in the inner loop ( to wheter print an asterix or a space) by studying the values of the loop variables at the edge of the square.

  • Fixing CAD Program Paths

    I'm often asked to edit drawings that were created in engineering CAD programs. I keep running into the same problem where Illustrator can't fill a closed path completely, and I can't find a workaround yet for this.
    Let's say I have a closed path of a basic shape, with rounded corners. (Well, I assume it's a closed path. It sure looks like it to me.) If I select this shape and fill with black, only the corners are filled black. The rest of the shape remains white.
    I'm looking for a command in Illustrator CS3 that will correct this path, so the shape will fill entirely with black.
    Can anyone comment on this, or offer a fix?
    I've asked the engineering guys to look into their Export or Save As settings on their end, but there doesn't seem to be anything. I have been receiving .AI files and also AutoCAD .DXF format files, if this is of any help. I also understand some of these files are drawn in SoftWorks.
    Thanks in advance for any potential help in fixing these simple paths.

    i've had to bring lots of cad files into illustrator and that's always a drag and non of the solutions are quick.
    you can use the plug in Concatenate to join segmented paths - this will require you to do one object at a time for clean results. you can do a whole document but you might end up with multiple merged objects etc. it's also not always clean, depending on your object you might end up with multiple lines on top of each other. but in general it helps a lot.
    one helpful thing to do before using it is to get rid of anchor points before joining.
    another way i've been working around this is by using the Live Paint. select the lines enclosing the shape you need and paint fill it.

  • How to create a directory or Folder  using java program?

    Hi all,
    Can any one know, how to create a directory(new folder) in java.
    can any give me some idea, on creating a directory using java program dynamically.
    thanx in advance

    hi thanks for your answer,
    sorry, actual i know this technique(its my fault i didnt mentioned it)
    i am looking for some what different technique.
    bye
    ram

  • How to create a  schedule program in java

    Hello Friends ,
    Can any one provide me with an example how to create a schedule program using java.util.timer etc . I am in need of a program which should run as a schedule job that searches for a file in a directory and read the latest files from that directory in every minute of time as a schedule job .
    Thanks
    mahesh

    I don't feel like writing my own example, but google will be happy to provide you with an example.

  • Is it possible to create java standalone programs with java ME 8

    Hi,
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    When working with java SE, I usually make standalone programs.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    The reason for asking is, that I often make small tools in java that ae then called from a linux script. I imagine that this might be useful on the raspberry pi as well.
    Thanks in advance
    Jef

    Hi Jef -
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    Sort of - similar life cycle methods - so conceptually, yes.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    In a way, yes. If you build an project, you will notice a JAD file and JAR file in the dist directory of the project.  JAD is the descriptor for a MIDlet - in mobile devices, the JAD
    file is loaded first to determine if the MIDlet has enough privileges to load and run, before the corresponding JAR file is downloaded.
    However, the JAD file can also be included in the Manifest of the JAR and the JAR copied to the embedded device manually and run there.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    You can build JAR files and include them into Java ME Embedded projects, but just like Applets, to use the Application Management System (AMS) on the Raspberry Pi, you must have a MIDlet to run.
    Perhaps you mean that you would like to launch the AMS and load a MIDlet from the command line on the Pi?
    If so, take a look at this section of the Getting Started Guide for the Raspberry Pi.
    Tom

  • How to creat a Dialer Program in Java

    Help me in creating a Dialer program which dials to a specifie ISP.It should work like the Dialer provided in windows.Help!! Can we code such a program in JAVA.If yes, HOW!!!!
    Abhishek([email protected])

    Get the Java Communications package - javax.comm (comm.jar)
    This will give you access to Windows/Solaris serial (and parallel) ports from Java.
    You then need some simple modem handling to perform the dial and initial handshake.
    Steve

  • What is url and how it should be created thru program in java

    Respected people,
    could You please tell me what is a URL in java ?
    and
    How the Url is programmed in java
    Regards,
    Kamakshigopal

    Respected people,
    could You please tell me what is a URL in java ?
    and
    How the Url is programmed in java
    Regards,
    Kamakshigopal

  • Hobby CAD program recommendation? Where is spread sheet on iMac

    Hello
    Originally I was replying to J.C. in another thread about software. The question was answered with a star so not sure if J.C. or other question answering types will look at it so I am requizing here.
    Sorry this is a bit stream of couciosness but my basic question is: what app has drawing capability freehand and CAD, desk top publishing enough to take notes and add pictures and can calc with a spreadsheet.
    The following is how I arrived at the above question.
    Is there a basic spread sheet that came with my 2007 17' iMac? I just use the one on my old computer. Looking through the apps I just see a demo of Office. Back in the day I purchased Wings for my Mac SE to have a spread sheet (didn't come with an s sheet).
    Any recommendations on a desktop publishing app with drawing capability that integrates with above spreadsheet? I use it for taking notes and designing things for hobby. Metal working, furniture, etc.
    I have Publishit Easy on Mac SE. I was writing employee manuals back then. Then my life took other turns and now I am back as if dropped from the past into the future. Help!
    Back then 1989 when I was shopping for a computer, at the Mac store I said I wanted one I could upgrade to be able to use a basic cad program. Rather than educate me they just laughed. I bought else where. They called the store microage I fondly remember them as stoneage. They are out of business. No wonder.
    Within a few years my friend was using a cad program on his laptop. Stoneage had no vision.
    Perhaps I want a Cad program now. Still need to integrate/do the above with it. Should I enter this as a question in another forum here?
    I assume any cad I would get now would be a bit over the top for what little I want to do (no cam use).
    sincerely
    Barkingmad

    There is Office for Mac but you will have to purchase it and dump the trial that came on your Mac as it will expire after 30 days. Office comes with Word, PowerPoint, Excel, and Entourage(email client). Excel does spread sheets, PowerPoint does presentations and Word creates documents. You could also get iWork for your Mac which are Apple's version of Word, PP, and Excel.
    http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?nnmm=br owse&mco=8006AFCD&node=home/mac/campaigns/msoffice_2008landing
    http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?mco=A8E E25ED&fnode=home/shop_mac/software/apple&nplm=MA790Z/A
    I'm not too familiar with CAD applications for Mac so you'll have to do a little research unless someone else can chime in. I just typed in Google "CAD for Mac". When you find one that looks good then go back to Google, type in it's name and look for some reviews.
    http://www.apple.com/downloads/macosx/imaging_3d/domuscad.html
    http://www.turbocad.com/TurboCAD/TurboCADforMac/TurboCADMacProv3/tabid/586/Defau lt.aspx?gclid=CPLH5aGxiJECFSBeagod6laaFQ
    George

  • Legacy C program - new Java GUI and calling methods

    Hello,
    I am fairly new to these forums. I've been working for a company that has an exsisting program that is a propriotery video-client to a video-server. It is written in C and has DirectX components for the standalone C application and ActiveX components for the Internet Explorer version.
    I looked over the source code and found a main() function. Now I am trying to execute that main() fuction through java and jni. I have managed to get a simple HelloWorld program to work but am now stuck.
    I would like to do the following.
    1. Convert the exsisting code to a C library. I have to use Visual C++ 6.0 to create this project. (There is already an exsisting dsw project file for the video client).
    Question: How do I get rid of the main() function and compile correctly in Visual C++?
    2. How do I call the library function that I created in the above from a java main() method? What should I use to edit and compile java/c code?
    Thank you,
    Viral

    Hi,
    If you need to have fast results you can try to use the ActiveX with COM bridge like Jawin or JACOb (both at sourceforge) or use Eclipse's SWT that has an activeX support too.
    An other alternative is to create a full JNI wrapper to your project.
    A1 : Replace the main by DllMain (create a new DLL with msvc++ wizard to see how to create a basic DLL).
    A2 : Call all functions exported by DLLs with a free tool like JNative.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Creating sales order using web dynpro JAVA

    Hello everyone,
    i am new to web dynpro. Can any one tell me how to creating sales order by web dynpro JAVA using BAPI.
    Thanks.
    Vinita Sharma

    Hi...
    you can use Adaptive RFC methodology in web dynpro java to work with BAPIs..... these are standard bapi's provided
    Here are required Bapis... select which one you want....
    BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
    BAPI_ORDER_CHANGE_STATUS_GET Change status for order
    BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
    BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
    BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
    BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
    BAPI_SALESORDER_GETSTATUS Sales order: Display status
    BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order
    check this thread SALES ORDER creation using BAPI
    sample java program which will call SAP bapi function sales order create
    PradeeP

  • Exporting DXF with Coordinates Illustrator to CAD program

    Hi,
    I often have to export graphics from Illustrator CS5 for use in Catia or Pro Engineer.
    Usually, if it's a graphic I have made myself, all I do is drag the 0,0 on my rulers to the position on the artwork where I require the coordinate system to be placed in the DXF file and that's fine.
    However, recently I have received files from other sources which need to be converted from a PDF to a DXF for use in my CAD programs and I am having difficulty relocating the coordinate system to the desired location.
    For instance, if I convert the PDF to DXF without moving my 0,0 location on my rulers, sometimes the coordinate system is top left or bottom left of the artboard the PDF has been imported into Illy on. (It varies file to file). So I figured that if I move the 0,0 location of my rulers to where I want the coordinate system to appear, that should work because it usually does so in artwork I create. But it always gets overwritten. The only way I can counter this is to assume that the coordinate system is bang-on the corner of the artboard and move all my artwork to the corner and then convert the file to DXF.
    I guess my question is, for those of you who have a similar task to do, is this the only way I can relocate the coordinate system (by moving the artwork to the corner, which seems a bit dodgy cos it's all on assumption) or is there a more accurate way to do so.
    Thanks in advance.
    Sonya

    I o not know if that is the only way but I will point out the reason you might be seeing 0,0 either at the to left or lower left is that in Cs 5 it has been change to the top left i CS 4 and earlier it was the  bottom left, so depending on what version it was created from it might change this for you as well a way of changing this for you is to ask from them to save the file as an ai fie first in a version that is CS or earlier than make that a pdf.
    Or what might be easier is to live with it until everyone changes to CS 5 or later?
    Or make it a symbol and use the orientation proxy in the symbols options to select the orientation you desire.

  • New "Windows Programming Using Java" Website

    Our newly created "Windows Programming Using Java" website (http://fivedots.coe.psu.ac.th/~ad/winJava/) is for programmers who want to extend Java's capabilities on Windows XP and/or Vista, but aren't sure where to start. One of the drawbacks of Java's portability is that many Java programmers have a rather sketchy knowledge of Windows-specific programming.
    We plan to explain how Java applications can utilize Windows application software, OS features, and hardware beyond the reach of Java's standard libraries. A variety of Java/Windows programming techniques will be explained, including:
    * Java's employment of the Win32 API via C, JNI, and J/Invoke.
    * Java's utilization of Window's Command Line Interface (CLI) and batch files, accessed through Java's Runtime, ProcessBuilder, and Process classes.
    * Java and Windows object-based scripting, centered around the use of VBScript, Windows Script Host (WSH), and Windows Management Instrumentation (WMI).
    * Java interoperability with COM, including hosting of ActiveX controls in Swing containers using jacoZoom.
    This website is a work in progress, with four chapters available for download at the moment. We'll be adding more regularly, and would love feedback on what we're doing.
    Thanks,
    Gayathri Singh and Andrew Davison
    [email protected] and [email protected]
    Edited by: AndrewDavison on Jun 20, 2008 1:36 AM

    Hi, I am looking the similar kind of requirement that you had done.. Do you have any more details on the code that is working for you . All i need is if the user logs in successfully in windows, the the app should be accessible. Please let me know if you have the code with you on this problem.
    Thanks in advance
    "what i meant is the we b applications running in my system, when i access the application iam able to to login automatically with windows authentication and now in case of other users following process happened:"

  • C:\Documents and Settings\User "c:/Program Files/Java/jdk1.5.0_14\bin\java.

    I have a class "Stimulus.java" in which another jar's class has been used. When I created jar and executed I got below error. I used "-classpath" to set dependancy jar file. Any clues are appreciated.
    import modulus.Modulus;
    public class Stimulus{
        public static void main(String[] args) {
                Model.main(args);
    C:\Documents and Settings\User>"c:/Program Files/Java/jdk1.5.0_14\bin\java.exe" -classpath "D:\User\mypgms\test\bin\Modulus.jar;" -jar D:\User\mypgms\test\bin\Stimulus.jar c:\test.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: modulus/Modulus
            at Stimulus.main(Stimulus.java:4)

    You can't mix classpath values with the -jar option. Using the -jar option causes Java to use only the Class-Path: information in the jar's manifest file, while ignoring all external classpath information. Review this for details:
    http://java.sun.com/docs/books/tutorial/deployment/jar/run.html

Maybe you are looking for

  • Mobile Applications folder missing

    Hello everyone, I am trying to acces files, which are supposed to be located inside the "Mobile Applications" folder, which should be located at C:\Users\<username>\Music\iTunes\iTunes Media. However, this folder is missing. The only things that are

  • Bind parse errors

    Oracle 11.2.0.1. Background: doing "multi-threading" using DBMS_PARALLEL_EXECUTE, which uses the bind variables +:start_id+ and +:end_id+ when executing a "thread". The Problem: Oracle chokes on parsing a bind variable used in a FOR loop. Example: //

  • TS3989 Missing pictures

    I am missing a lot of pictures in my photo stream how do I retrieve them

  • Fetching characters from a variable string

    I have a TicketNo in this format: 00345-4-7-0201 In the above string 02 is a code which can be 01,03, etc. I want to fetch the two characters after second hyphen '-'. substr function is difficult because sometimes the size of the string increases by

  • Portal run time error while accessing R/3 transaction code

    Hi all, We have configured R/3 system and BW system to the Portal. In R/3 system we have user ids named "ADMIN" and "FIAR" . ADMIN is for adminstrator and FIAR is for FIAR module. I created the same user ids in Portal , for ADMIN i have assigned ADMI