How do you integrate fortran code with a java gui?
I have a fortran program that accepts input via a file开发者_StackOverflow社区 (*.dat or whatever).
I'm planning to make a GUI (probably using SWT) that would construct the input file based on user input (through forms: textboxes, drop downs, etc).
The problem is, I've never done this before. Is there any standard way to go about this? I'm pretty sure a lot of people have done this (based on google searches), I just have not seen a standard approach for this.
You can have a look at gtk-fortran: https://github.com/vmagnin/gtk-fortran/wiki
The gtk-fortran project aims to offer scientists programming in Fortran a cross-platform library to build Graphical User Interfaces (GUI), licensed under GNU GPL 3. Gtk-fortran is a partial GTK / Fortran binding 100% written in Fortran, thanks to the ISO_C_BINDING module for interoperability between C and Fortran, which is a part of the Fortran 2003 standard. It offers interfaces to around 10000 GTK functions (GTK, GDK, GdkPixbuf, Cairo, Pango, ATK, GLib, GObject, GIO).
Note that gtk-fortran goes beyond programming GUI: GTK includes the crossplatform GLib library which offers a lot of generic functions (regular expressions, random numbers, hash, strings, input/output...), and gtk-fortran offers also an interface to PLplot.
Although mainly developed under Linux, you can easily use it under Windows via MSYS2. It runs also under UNIX systems like BSD, macOS and Raspbian on the Raspberry Pi.
I get the feeling you're under the impression that you cannot make a GUI in Fortran, no?
So, here are a few links to try to shake that one ...
Compaq Visual Fortran: A Guide to Creating Windows Applications
Winteracter
GINO
And M.S.B. already mentioned my personal favourite, DISLIN.
(I'm sure there are others as well, but these are the first that come to mind).
If you are now beginning with Java, I recommend that you use Netbeans for the development. Netbeans provides a form designer that will make your life easier (uses Swing and not SWT). When you have your file ready, you can start the Fortran process with ProcessBuilder.
In case you don't know about it, it is possible to construct a GUI with Fortran code, e.g., using the DISLIN graphics library.
精彩评论