Sunday, July 12, 2009

GUI and Graphics - how to learn to program?

I started in computers back in the 70's, but haven't kept up with the newer things, I am now trying to catch up. I have been mostly programming for working with data, now I want to learn how to do graphics in a Windows environment. I have tried some C++ and Java, only to hit roadblocks because I don't know how to find the right libraries / compilers.


I want to write a program that has a GUI driven window that reads data coordinates to draw special maps, then have the option to print or save the maps. I have done the map drawing in an old version of BASIC, but this can't read mouse coordinates and only has 16 colors..


Can someone please recommend a path that will teach me how to learn how to do this in a newer language? What product can I buy or files to download that has all the needed libraries, compilers etc to make the program work in WIN XP?


I am not near a university, the small local college has no answer for me. Such is small town Kansas.


Many thanks!


sudonym@yahoo.com

GUI and Graphics - how to learn to program?
So many options, the most basic language for creating GUI's is a RAD (Rapid Application Development) language, such as Visual Basic or Delphi. I personally favour QT http://www.trolltech.com with C++, the GUI toolkit is very powerful and interoperable. Though if you're not friendly with C++, it might be a tad tricky to pick up.





For windows, you can use the Win32 API with most languages, I hate to suggest it, but if you're familiar with Basic, then I suggest picking up a copy of Visual Basic, http://msdn.microsoft.com should contain all you need to know.
Reply:You can use C++ or Java for this. I personally would recommend Java for starting out. I think the way it's graphics work are much more intuitive, although C++ and MFC (graphics libraries) get used a whole lot more in the production world.





To get started doing a GUI app in java, download the NetBeans IDE with the JDK 5 bundle at http://java.sun.com/j2se/1.5.0/download-...





Netbeans has a GUI wizard you can use to make your app and then just flesh out the code if you like.





If you prefer to roll your own, the libraries you will need to use are the javax.swing.* classes.





Sun has very good tutorials on their site http://java.sun.com/docs/books/tutorial/...





I would recommend that you start by getting a JFrame on the screen. I would then probably use BorderLayout on the Container inside JFrame and add a JPanel in the center to draw on. You will need to override the paintComponent method to do your custom drawing. All this will make sense as you look at the tutorial...





From there you can create another custom JPanel on the in the Left portion of the screen where you can add your JTextFields and JButtons for data entry. You will then need to add some event handlers to your GUI so that you can submit data. Look at java.awt.event.ActionEvent for this.





Hope this Helps


No comments:

Post a Comment