This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Simple GUI for math programs

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first post, on almost any site. I need a simple GUI for JAVA for Windows for programs that do mostly math manipulations. The user needs to be able to know the program is running, know the program has ended, be able to specify file locations for input and output, provide names for new files, and see where output has gone. This should not be fancy. It should allow the user to "browse" to specify file locations rather than have to type in full directory locations. For example, I have a program that figures kinship (relatedness) indicators between two people in a population. I originally learned Pascal, C, and C++ a long time ago but did not make it to GUIs. I can render all my old programs into JAVA easily enough except for simple GUIs (console alone not enough). Without a GUI, modern users are stuck, and all my old programs are useless. Any help much appreciated. I will learn fancier GUIS later. You can hand me some code, or I am open to other sources such as books (don't have a lot of money to spend these days). Thanks a lot.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Your first resource for building a Java GUI should be The Java Swing Tutorial. I think you'll find everything you need there.

If you're building a GUI (especially a Java GUI) for the first time, don't be overwhelmed. There are a lot of steps and a lot of pieces to manage. So understand that this will not be a "quick code insert." Be prepared to spend some time on this.

I strongly recommend looking at the Model-View-Controller (MVC) pattern. This will help you set up your code in a manageable way. You mentioned that you can already translate your old programs in Java to work with the console. That's excellent, because this is the "Model" component of the MVC pattern. The GUI is the "View," which should be entirely separate from your logical model. The "Controller" is the piece that connects the Model and View.

Finally, we have a forum dedicated to GUIs, so I'll move this topic there for you. Please continue in that forum.
 
Rancher
Posts: 3441
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you'd like a very simple GUI builder that generates AWT code try this:Simple GUI builder

It presents an empty window that you can RC on to add components. The components can be moved around and resized. The code has lots of weird features (bugs) but I've been able to use it to put Q&D front ends on various utilities that need user input as you describe. If you'd like to help me remove some of the bugs, let me know & I'll send you the source.
Good luck,
Norm
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Norm Radder:
If you'd like a very simple GUI builder that generates AWT code try this:Simple GUI builder

It presents an empty window that you can RC on to add components. The components can be moved around and resized. The code has lots of weird features (bugs) but I've been able to use it to put Q&D front ends on various utilities that need user input as you describe. If you'd like to help me remove some of the bugs, let me know & I'll send you the source.
Good luck,
Norm



I don't think this is helpful for three reasons:

1. Being new to GUI coding the OP shouldn't concern themselves with builders. They need to dig in and write the code so they can learn it.

2. AWT based GUI's are so 1998. In this (java) day and age building GUI's with Swing is the way to go, builder or no builder.

3. If a gui builder must be used there are several excellent quality bug free tools available. Netbeans Matisse, for example. Or JFormDesigner.
 
Norm Radder
Rancher
Posts: 3441
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the OP should learn Swing. No differences there.
However, there is a LONG learning curve for Swing and for IDEs.

A lot of utilities I've written have taken longer to put a GUI on them than all the rest of the code and a lot more. That's why I wrote this simple program. On my first computer Swing was so slow that I could watch the components as they were placed in the layout. AWT was a lot faster.

While studying Swing and how to use the IDEs he can play with my simple tool.
The problems with IDEs for beginners is there is TOO much magic involved. Knowing what goes on underneath will make a better programmer. Another problem I've seen is that the new version of Netbeans came with java 1.6 and required all users of its output to have 1.6. Not all non-programming users are interested in having to install a new version of java.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Norm Radder:
While studying Swing and how to use the IDEs he can play with my simple tool.



What good does it do to try and learn swing by using AWT widgets? No one develops GUI applications using only AWT anymore. I'm not saying your tool is bad. I'm just advising the OP that using it might be converse to what they are trying to achieve, learning Swing.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little bit of a tangent I guess, but I've always wondered why GUI development in Java moved from AWT to Swing/SWT. Is it because of L&F, limitations of AWT, both, or more?

I only got onto the GUI scene about a 1.5 years ago.
 
Marshal
Posts: 65799
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At least partially L&F; an AWT GUI looks different on Windows, on Unix/Linux and on Macs.
 
Sheriff
Posts: 21804
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Availability of controls is another. Swing has tables and trees for instance, whereas AWT doesn't.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!