Results 1 to 7 of 7
- 08-03-2012, 04:25 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 3
- Rep Power
- 0
Terminal loses focus, what's the alternative?
Hi all,
I have a Java program running on a computer that accepts scans from a bunch of networked bar code scanners. The scanners send the bar code and then "Enter", which enters the data and starts a new line (using a while(true) loop and BufferedReader.readLine). I have not made any kind of an interface, just using the terminal. There's no direct interaction between a user and the computer so there isn't a need for an interface.
My problem: The terminal will lose focus over time, so any "keyboard" input is lost. I have tried putting the command prompt into full screen however this does not work, it will eventually revert to the desktop. This is bad 'cause I lose scans and then the foreman comes and complains when his data isn't accurate :-[
1) Is there any way (maybe non-Java related) to gaurantee the command window always has focus? Does it matter if I "C:\java programname" or programpackage.jar and run that?
2) Would a full-screen interface maintain focus? Looked a little confusing to figure out but worth it if it solves my problem.
Thanks in advance for any help!
- 08-03-2012, 07:11 PM #2
Re: Terminal loses focus, what's the alternative?
Thread moved from Java 2D. What made you think this question might belong in that section?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 08-03-2012, 07:57 PM #3
Re: Terminal loses focus, what's the alternative?
How do the scanners "write" on the console? Is there a way to have that input go to the java program?
If you don't understand my response, don't ignore it, ask a question.
- 08-03-2012, 07:59 PM #4
Re: Terminal loses focus, what's the alternative?
When you say you're using a terminal, do you mean a Java terminal like de.mud.terminal.Terminal from JavaSSH? If so, you might be able to gain focus whenever input is expected. See JComponent (Java Platform SE 6). But if you mean you're using a Java program running in a native terminal, it's probably a question for a forum dedicated to your particular OS or window manager.
Get in the habit of using standard Java naming conventions!
- 08-03-2012, 08:29 PM #5
Member
- Join Date
- Aug 2012
- Posts
- 3
- Rep Power
- 0
Re: Terminal loses focus, what's the alternative?
I mean it's running in a native terminal (XP Pro). The scanners are HID devices and are just like a keyboard. The small part of my question, just in case someone who reads has a viable solution that isn't Java related, is how to keep focus.
My actual Java question - would an interface of some kind be able to maintain focus all the time, or regain it if lost? Would going fullscreen prevent anything else from being able to steal focus? The machine is always running. It loses focus every few hours, and the only way I can restore it is using VNC. It would be ideal if it could run 24/7 and always be able to ensure it has focus.
- 08-03-2012, 09:21 PM #6
Re: Terminal loses focus, what's the alternative?
A Java GUI might be able to request focus. See How to Use the Focus Subsystem (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features). But it depends why it's losing it in the first place. This is a very OS-specific question, and you'll probably get a better answer on a OS-related forum.
Get in the habit of using standard Java naming conventions!
- 08-21-2012, 01:36 PM #7
Member
- Join Date
- Aug 2012
- Posts
- 3
- Rep Power
- 0
Re: Terminal loses focus, what's the alternative?
Kind of an old thread now, but in case someone encounters the same issue and wants a quick fix:
I first tried using a task scheduler that would close my app, and then run it again, and set cmd to run full screen. This worked all the time, except for some reason when it would kill/run at 5:00 am the java.exe window would APPEAR to have focus in the taskbar but didn't.
So then I tried software that automatically clicks in the middle of the terminal window every minute, and it's fine. There's still that narrow amount of time where it may lose focus, and receive text before it gets clicked, but I think I'll accept 99% accuracy.
Similar Threads
-
bufferedReader (or alternative)? Help!
By seven in forum New To JavaReplies: 1Last Post: 02-29-2012, 04:56 AM -
Stop JFrame from requesting focus so parent creating JFrame has focus
By robme in forum AWT / SwingReplies: 7Last Post: 12-27-2011, 03:06 AM -
Alternative to JNLP
By tecno40 in forum Java AppletsReplies: 1Last Post: 12-31-2010, 08:28 AM -
Mac Terminal
By Java8 in forum Other IDEsReplies: 0Last Post: 01-16-2010, 06:19 PM -
Terminal
By dj kourampies in forum New To JavaReplies: 7Last Post: 01-07-2009, 03:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks