Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java Loses focus when printing

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Location
    St. Louis
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Loses focus when printing

    I am working on a Java program to monitor meal consumption by members of an organization. They swipe their ID cards, enter PIN, and number of meals they want. System knows if dining room is open and what meal based on time. The system then prints out a receipt on an Epson TM-T88IV receipt printer.

    The system is running in console mode. My problem is that when the system prints, a Notepad window pops up for milliseconds and then the Java program loses focus. The screen reverts back to Windows home screen. I'm using Windows XP, SP3 and the latest Java build.

    Any suggestions on how to prevent the loss of focus would be greatly appreciated.

    Thanks!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Java Loses focus when printing

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Java Loses focus when printing

    As far as I understand you are running from command line. If the command line loses focus there is nothing you can do because this has nothing to do with java.
    Java can not control the focus of native windows, only of Java Swing frames (or AWT perhaps).

  4. #4
    Junior Member
    Join Date
    Aug 2014
    Location
    St. Louis
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Loses focus when printing

    Quote Originally Posted by Cornix View Post
    As far as I understand you are running from command line. If the command line loses focus there is nothing you can do because this has nothing to do with java.
    Java can not control the focus of native windows, only of Java Swing frames (or AWT perhaps).
    Cornix,

    Many thanks. I suspected this was the case but wanted to make sure I was not missing something in Windows settings that could prevent the focus loss.

Similar Threads

  1. how to stay focus learning java?
    By malayo in forum Totally Off Topic
    Replies: 3
    Last Post: October 27th, 2012, 11:10 PM
  2. Replies: 1
    Last Post: September 28th, 2011, 07:29 AM
  3. KeyListeners: Automatic Focus?
    By bgroenks96 in forum Java Theory & Questions
    Replies: 32
    Last Post: June 24th, 2011, 09:03 PM
  4. [SOLVED] Printing Array without printing empty elements
    By CarlMartin10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 12th, 2010, 02:41 AM

Tags for this Thread