I have been able to successfully access information given from Swing Components on Mac
using a seperate Runtime process and feeding back the data into the captured system output stream.
For those like me, who simply want basic InputDialog access, here is a library im working on
bobjob_util.zip (http://users.on.net/~bobjob/tools/bobjob_util.zip): source included in package
Here is an example of a input dialog, message dialog, and file chooser
import java.io.File;
import javax.swing.JFileChooser;
import com.bobjob.engine.util.swing.SwingHandle;
public class SwingTest {
public static void main(String args[]) throws Exception {
//Create Swing Instance, that Locks the Thread
SwingHandle swing = new SwingHandle(true);
//Input Dialog and Message Dialog
String message = swing.showInputDialog("Enter value");
if (message != null) swing.showMessageDialog(message);
//set file chooser dialog settings
swing.addChoosableFileFilter(new String[] { ".jpg", ".bmp", ".jpeg", ".png" }, "image files");
//open file selection dialog
swing.setMultiSelectionEnabled(true);
int selection = swing.showOpenDialog();
if (selection == JFileChooser.APPROVE_OPTION) {
File file[] = swing.getSelectedFiles();
for (int i = 0; i < file.length; i++) {
System.out.println(file[i]);
}
}
//change file chooser filter to accept all files
swing.addChoosableFileFilter(null, null);
//open a save dialog
swing.setMultiSelectionEnabled(false);
selection = swing.showSaveDialog();
if (selection == JFileChooser.APPROVE_OPTION) {
File file = swing.getSelectedFile();
}
//destroy swing instance
swing.dispose();
//make sure to call GLFW window focus after using swing
}
}
Given that I can run Swing on a seperate java instance, I was wondering if it would be possible to create an awt canvas for MacOSX using Remote Method Invocation(RMI), as long as all references to the swing objects are accessed on the remote instance?
Quote from: bobjob on May 21, 2016, 12:24:32Given that I can run Swing on a seperate java instance, I was wondering if it would be possible to create an awt canvas for MacOSX using Remote Method Invocation(RMI), as long as all references to the swing objects are accessed on the remote instance?
As long as the AWT/Swing and GLFW event loops run on different JVM instances, you can do anything you like. This is actually the recommended way to do Swing/GLFW interop and the only way that's guaranteed to work on MacOS.
I would recommend a different IPC solution though, something that doesn't hijack stdout/stderr and is much more efficient. You could try Disruptor (https://github.com/LMAX-Exchange/disruptor) over memory-mapped files or Aeron (https://github.com/real-logic/Aeron) IPC.
Why not localhost sockets? People used this back in the C and C++ times and you can still use them today. Sending to localhost is pretty quick too.
Quote from: Cornix on May 22, 2016, 16:01:50
Why not localhost sockets? People used this back in the C and C++ times and you can still use them today. Sending to localhost is pretty quick too.
When working with sockets, java can trigger firewall warnings. This has happened to me in windows, where I then have to set java access to private or public networks. I dont like having these warnings associated with my programs.
Even when connecting to localhost?
I am not too sure since I havent done it for quite some time but I dont remember any warnings when only communicating within the same machine.