• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JFrame focus

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have two co-dependent JFrames.
A button in Frame1 opens up Frame2, and Frame2 accepts some input.
The input in frame2 has some calculations done on it after a click event on frame1. The calculations are based on the location clicked in frame1.

What happens by default is; frame2 opens up, I give it some input, and then when I click on frame1 (to give frame2 the location to base its calculations on) frame2 disappears behind frame1, as it has lost its focus.

Is there a way of changing the focus so that when I click on frame1, the click will register, but frame2 will stay in focus and stay on top?

Thanks for your time,

Eoin.
 
Marshal
Posts: 79649
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked whether JFrames have a requestFocus() method? If they have, then try putting something like:-
in the actionListener for your button on Frame 1. If that doesn't work, have you tried "toFront()" and "toBack()" methods?

Just suggestions; I hope they work
CR
 
Everybody's invited. Even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic