I was rotating my jME3 scene object from Swing program. Unfortunately, rotations does not occur until I click jME3 canvas by mouse.
Is it possible to implement modifications immediately?
Is a question a long time ago and you have probably already found a solution.
I had the same problem and searched very hard for an solution.
For those who have the same problem, here is a link that might help.
http://hub.jmonkeyengine.org/t/swing-canvas-and-events/21352/2
Conclusion:
It is a problem of the lost focus in JME canvas.
You can solve it with 2 line code!
First: choose on appsetting: setPauseOnLostFocus(false);
this make your update methode run also when lost the focus, by clicking on swing components
Second: Also set the focusable property for the other controls in the windows to false with: object.setFocusable(false);
I hope I could help.
Best regards.
EsKay.
Related
I'm developing a plugin for IntelliJ IDEA, which obviously uses Swing.
For a feature I have introduced I'd like to stop a JPopupMenu which uses JCheckBoxMenuItems from losing focus and closing.
You can see it in action.
I've debugged the code, but I couldn't figure out how to do it, also being I'm not that into Swing.
Could you maybe point me to useful listeners/blocks of code/ways to prevent this?
If you want to see code, the IntelliJ classes are
ActionPopupMenuImpl.MyMenu
ActionMenuItem
Edit: a better way need to be found as the uiRefreshed event isn't always called at the right time.
Just coordinate your code in a good way ;)
The Swing mechanism in IDEA is too complicated, and maybe it's better to not touch it. Just know that the mouse events are handled by a special listener and then redirected to Component(s).
That said, having an hold on the menu ActionButton. You can listen for the Lookup's uiRefreshed event and programmatically:
myMenuButton.click()
That's all.
You need to call it after the UI has been refreshed because the LookupUi might have changed in dimension or location.
Apps like Floating Toucher or Link Bubble proves how useful a floating button can be. And no, I'm not talking about FABs as per Material Design guidelines here, I meant a literally 'floating' button that draw over any screen in the system that can be dragged around and clicked.
Take a look at these examples:
(source: boatmob.com)
Now, I tried to Google a way to do this but I'm afraid I'm still at lost here. How can these apps draw over screens outside their own?
I've come across this SO question which more or less asking about a similar question. But to be honest, I wasn't able to gain much information from it. Said question mainly addressed how to intercept a touch for a floating view; Not how to specifically make one.
I really hope that somebody out there could enlighten me on this. Thanks in advance for your time!
If you are talking about an activity's view (not Widgets), 'floating' on screen, like Facebook ChatHeads. Then you should create a background service and attach a view with it. Though it is not recommend by Android.
See below links
What APIs in Android is Facebook using to create Chat Heads?
http://www.piwai.info/chatheads-basics/
I want to customize a JLable to make him clickable, i'm not talking about adding an Action Listener because i already have, i'm talking about changing the mouse cursor's reaction when the JLabel gain Focus just like the reaction of a mouse hoover on a link in the browser.
I have impression that is not possible with swing.
How about:
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Swing APIs have a way of doing it:
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
and when you change your mind:
label.setCursor(Cursor.getDefaultCursor());
I have impression that is not possible with swing.
Or maybe you just haven't yet learned how to do this perhaps? A MouseListener and MouseMotionListener have worked great for me.
Edit: and setting the JLabel's curser as noted by Max -- 1+ up-vote for him!
so I have been working on developing a GUI for an upcoming project,
and I have to admit that even after about 2 years of Java, I'm still not good at GUI design and programming.
First of all, here's a screenshot of the current version of the JFrame:
I made a little custom JPanel that is going to display a graph later on,
for now it's just random. It's the thing in the lower right. Now if I just repainted that and did all my stuff, nothing would be wrong, but I have to update the JTextArea (which is included in a JScrollPane by the way), I every time set the caret to the very last position, so that it automatically scrolls down. And this causes, in my own custom JPanel, small dots and lines to appear and flicker, which I believe is caused by the JTextArea.
When the window has certain proportions, or if I don't update the caret position, this doesn't occur.
I have already tried a few things: Synchronizing everything related with the EDT, scheduling my repaints, etc. but nothings seems to help.
Has anyone ever come across a similar situation and knows how to fix it?
I could really use some help here.
Thanks in advance,
Tom S.
I think is too hard to say something wise in conections with #camickr's Text Area Scrolling
I have music Applet which uses keyboard, mouse and GUI buttons. When applet is first loaded keyboard events work fine, as do mouse events. However, after I have pressed one of my GUI buttons the mouse events still work but the keyboard events don't, and don't start working again until I refresh the applet.
After hunting around on the net I found some posible solutions, I've tried adding button.setFocusable(true); and button.addKeyListener(this); to all my buttons, and and my panels. No effect at all. I've seen recommendations for converting to a JApplet and using key binding, but surely there must be a simpler way?
Sorry for the lack of code, I've been working on this project since I was a newbie and it's a bit of a mess, and very long!
Any help much appreciated!
button.setFocusable(true); and button.addKeyListener(this); to all my buttons
For JButton use Swing Action or default implementations for ActionListener, rather than KeyBindings (for Swing based Container and JComponents), nor using KeyListener
EDIT
if isn't there really important reasons, don't use prehistoric AWT Applet, use JApplet, may be sufficient would be plain JFrame
Try to cut the problem area out of your project and put it here. Its highly probable, than while localizing the problem area you'll find some errors already.
If your project is a mess already, then the first and the most important thing you should do, is to order it. If it is a mess for you, that means you don't understand it. So, it simply can't work. That is your first and main error.