Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

JFrame focus  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have tried to find a solution to the focus problem , but none of them seem to match my criteria.
I have 2 Jframes ,FrameA is the enquiry screen , which calls FrameB. Once FrameB is visible it should have the focus and I don't wan't FrameA to take focus , even if the mouse is clicked on it , but it should be visible, and a beep sound should come. Only when FrameB is closed FrameA should get the focus.
Now here is what I have already done,
1. requestFocus()on FrameB,
2. FocusListener and focusLost() method has requestFocus() again.
3. When calling FrameB from FrameA , on FrameA I added FrameB.requestFocus().
But none of them seem to work. Whenever I click on FrameA , it becomes active.
Can anyone give me any suggestions.
Thanx mates.
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Did you look at ( modal )JDialog. You can replace FrameB
with a JDialog( call setModal(true) on it. This will make
your JDialog a modal dialog )
 
Vijay Mitra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I cannot do that with a JDialog , I have got a JTable , few buttons and many other interactions in this frame . I need the frame but having a fixed focus on it until its active.
Is it completely impossible with a JFrame ?
Thanx for your suggestion.
 
Vijay Mitra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shankar ,
I have tried with JDialog and it seemed to work as I wanted . Thanx for the tip yaar.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!