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
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'll start by saying that i'm kinda new to Java, so if i'm doing something obviously wrong don't insult me please...
I am having trouble finding a way to display different images in different positions in the same JFrame/Canvas, I've tried using Graphics, but if I write it as public void run(Graphics g) then thread.start() will not recognize it as its run method and nothing will happen.
In summary I can't find a way to use thread's run method to diplay multiple different images in the same Frame, hope I've been clear enough (if not just ask me what I meant).
I want to write an address in the address bar of a browser as well as click on a link using java Robot class. How can I track the different objects in a certain window?
Just giving a look at the API http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html, anyone who do this should know that via Robot Class there is no "trackComponent(Component specificComponent)" method, you got 2 things that may help you:
1-getPixelColor (more than help, seems useless for you by now, maybe i'm wrong).
2-createScreenCapture.
the second method is maybe the answer for your problem, you could take a picture of the screen and with some image processor (javaCV could help you on this: https://code.google.com/p/javacv/) you could then track the components on the screen you took (for instance: from pixels xxx to pixels yyy is the Address bar of browser), of course you need to read some documentation about javaCV (OpenCV) for get this done, after that just use the method for move cursor and enter keys for fill the components, hope someone give a simpler way to do this, but i think this way you learn a bit of JavaCV a really powerful tool.
I'm currently attempting to use the openoffice API to display a powerpoint presentation from Java - I've got a fair way in that I've managed to open a presentation and display it. However, there's a couple of things that I'd like to be able to do I can't figure out with the API as it stands:
I don't want the main Impress window to appear, just the presentation window. Now, I can start it minimized no problem with a property, but then the actual presentation window is minimised as well, which I don't want. I can also grab the window and call setVisible(false) on it, but it's still visible for a second or so while it's loading.
I want to be able to control the monitor which the presentation appears on (I'm using it in a multi-monitor setup.) I thought I might be able to grab the Window of the presentation and move it around that way as I need to, but I can't see how - for the main window I can do something like:
XModel xModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc);
xModel.getCurrentController().getFrame().getContainerWindow().blah();
...but I haven't yet found a way to get the presentation Window. I'd like to be able to set the bounds of the window directly (x, y, width, height) rather than just being constrained by positioning on a single monitor.
I can live with the first point, the critical one I need to solve for my use case is the second.
Any ideas on the above? I'm an experienced Java programmer but new to UNO.
Seems the second point can be solved, ish, with the display property:
public void start() {
try {
xPresentation.setPropertyValue("Display", 1);
}
catch (Exception ex) {
ex.printStackTrace();
}
xPresentation.start();
}
Note however a few of things - firstly the display index is base 1, not 0. Secondly, trying to set the properties in an array and passing them to xPresentation on creation didn't seem to have any effect - it only worked for me setting the property later as above. Thirdly, it doesn't allow fine grained control over the window as I wanted, just control of the display the presentation appears on.
The company I work for has an java application that runs on esmertec jbed JVM on windows mobile 6.
There is a requirement to capture a user's signature as part of some new functionality. One option is to try and implement this in java. This has been tried previously and has been found to be a bit slow.
I think the better option would be to get a native component to handle the drawing of the signature and save it to file. Does anyone know of a component that I would be able to use?
Creating our own component is an option as well but if there is one available already, I would prefer to use that.
For completeness, I'll answer my own question.
I could not find an existing component that done this. We ended up writing some c++ code that would handle this.
The code would get a handle to the Java canvas and register our own callback function with it. This callback function would record any mouse movement within the canvas and draw a line when necessary (either on mouse up or after a number of points had been drawn). Once the user leaves the screen we would save the canvas to file and re-register the original canvas callback function.