I'm trying to get data for my application from a form set in an external window (getDataWindow extends javax.swing.JFrame). The problem is that functions are executed before form is filled in.
getDataWindow dataW=new getDataWindow();
dataW.setVisible(true);
size=dataW.returnSize();
I've tried also adding additional boolean variable to getDataWindow
getDataWindow dataW=new getDataWindow();
dataW.setVisible(true);
while(!dataW.checkIfReady()){wait();}
size=dataW.returnSize();
But it makes also the window wait (it appears but it's black inside and nothing happens).
I think i should create some threads for that - I've tried to call a window making function getDataWindow in java.awt.EventQueue.invokeLater(new Runnable()) but I had to initialize dataW earlier so dataW.checkIfReady() could be called, so it is a catch 22.
Have you tried adding a listener in form contained fields ? I know you don't have full control over that class, but, well, it's some java code ! Run it in your debugger, and you'll see the code organization for that DataWindow. Then, you'll be able to add a Key/Action/Anything/Listener to trigger your code execution.
Related
Simplifying, I have this structure
Form {
tab=Container(BoxLayout.y());
other stuff
}
The Form is not scrollable (and it is not supposed to be), tab is.
At some point I want to redraw the Form to keep it up to date with some new info added, and I do that creating a new one and showing it.
But I want to scroll down the Container tab to its predecessor's Y-coordinate.
I can easily save the Y coordinate in a static variable using
scrolledToY=tab.getScrollY();
But I can't find a way to set it back when I create the new form.
setScrollY seems to be protected, and indeed if I try to run the program using it, I get an error
error: setScrollY(int) has protected access in Component
tab.setScrollY(scrolledToY);
What is the correct function to use, instead?
Thanks.
You can use scrollRectToVisible().
FYI you can just modify the container and call revalidate to update the UI. This will prevent a nasty refresh problem you might experience. Also check out InfiniteContainer which might be what you're really looking for.
I am able to use WindowsAccessBridge.dll to get access to java window (SwingSet2), and use the dll methods to interact with the controls.
I can iterate the tree (of java controls) using code shown here, and get information from the controls,
and I can do actions like SetText in Text box, or send click action to a button etc.
However, I am finding that the accessibility contexts are not consistent:
The SetText method works perfectly when I use the accessibility context got from the 'setMousePressedFP' method of the dll, after clicking on the text box.
However, I cant use the accessibility context got by iterating the control tree when trying to set text in a text box, although I verified that the other information e.g. size and other properties of the text box is same.
From this doc:
"The functions GetAccessibleContextAt and
GetAccessibleContextWithFocus retrieve an AccessibleContext object,
which is a magic cookie (really a Java Object reference) to an
Accessible object and a JVM cookie. "
However, the accessibility context differs everytime I click on the text box (without restarting the java program). The vmID matches eveytime.
If the AccessibleContext is really a Java Object reference, shouldnt I get the same AccessibleContext number everytime I click on the same control (without restarting the java window) ? and shouldnt that AccessibleContext number also be available in the tree?
Worst part is that the settext method doesnt work when I use the AccessibleContext got from iterating the control tree.
Edit to clarify the question further:
I am clicking on the same text box, so I would expect the windowsaccessdll function to return reference to the same control. As a long value the accessibeContext is different everytime I click, but its ok as the SetText method works everytime with the different long values and I can see the new text set in the text box.
The problem is when I iterate the control tree and the accessibility context got from the tree iteration doesnt work for the SetText method.
More specifically - how does the AccessibleContext compare to a c pointer - the c pointer would always be same when I get it for a specific control. The AccessibleContext appears to be a 8 digit long value that is different by few tens or hundreds based on where the mouse is clicked inside the text box.
Thanks in Advance.
I think this is so wrong, but I need it...
So, to run Processing's sketch in Java mode, you have to extends PApplet in the main class, and there, in the setup() determine the window size using size(int x, int y). Then when you run it, it'll show a Java window Applet Viewer.
What I wanna ask is, how to prevent that window from appearing? I've tried to remove the size method, but it appeared in (what seems like) it's default size. Tried put 0 as params, went wrong (the x and y have to be > 0).
Is there any way to do that?
If there's any lack information or I've made a mistake with the post, please tell me.
1st edit - add more info
Let's say I have 2 classes: the one that implemented Processing and extends PApplet is named Pikachu by me, and an ordinary Java class I named Jojo. Jojo will pass params to Pikachu and Pikachu will process that param. The param is image's name, or if it could, an image itself (I don't know yet tho, can Processing execute Image class from Java?). Then Processing will process that image, gave an output, again as image (Yet, again I don't know yet, can Processing gave output an image for Java to use?). So, that's why I don't need a window to appear.
Perhaps you can try to use the Frame object.
In the documentation there is a function .setVisible(boolean b)
If you call .setVisible(false) you can turn the frame off.
http://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setVisible(boolean)
I am not sure how to access the frame using pure Java. In processing you can simply call
frame.setVisible(false);
Hope this helps
I get the dialog for changing the properties of the print job by invoking the PrinterJob's printDialog() method without any parameter. There is a field where the user can change the the number of copies to be printed on the right-bottom of this dialog.
And now I want to disable this field (the spinner). That is only one copy to be printed and the user can't change it.
Are there any ideas for it
I don't think there is any way (or i am not aware of) to modify the native or the cross-platform Java print dialogs (last one might help you a bit). What you could do is maybe display your own dialog (without a spinner field) and under-the-hood do whatever you want (like PrinterJob.setCopies(1)).
More info i found here.
Also, have a look at the Java tutorial on PrinterJobs.
I've a problem with a Java Project, using SWT library. It's my first time trying with SWT, so don't throw stones to me please.
Environment: Eclipse - Juno
Class and functions:
1º Client -> Where's "main". Creates a object of "GUI_Creator" class (mine).
2º GUI_Creator -> Has 2 functions, in order to "desing" my forms.
2.1 -> MakeLogIn -> Void method, wich adds the controls i need to the Shell i give him as parameter. I use it, to desing the first form i show to the user.
This function also link the "click" event of a button of this shell, with the second function of GUI_Creator class, that creates a new one shell. Then, this shell would be open, and first one would be closed.
2.2 -> MakeClient -> This function returns a shell var. For me, this returns the second shell of my program, even with the desing, etc.
Problem:
I'm using, at the end of "main" this code:
while (!Conexion.isDisposed())
{
if (!ourDisplay.readAndDispatch())
ourDisplay.sleep();
}
ourDisplay.dispose();
If i'm not wrong, this code is doing that when i try to close my first shell, and then leave only opened the second shell, my program closes completely, because i'm disposing the parent display.
However, i can't delete this code, because if i do this, when i run my program, it doesn't "wait" an action, and just executes all "main" code and then closes the GUI and the program finalizes.
So, i really don't know what would i have to do, in order to fix this situation.
Thanks,
Btc
I'm not sure if I got your problem right, but you could try:
while (!(shell1.isDisposed() && shell2.isDisposed())) {
...
}