Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Focus problem  (Read 701 times)
0 Members and 1 Guest are viewing this topic.
Offline Grand Poeba

Full Member
**

Posts: 143



« on: 2006-01-21 18:54:03 »

Hey

As yo u may know i am working on a conversing of ttd but i am having thefollowing problem
When i let the user choose its resolution (by using a jdialog) before launching the game my jframe
doenst gain the focus when opening.
When i start my app without the jdialog first aeverything goes fine but when i use the jdialog before creating
the jframe it doens obtain the focus. Any ideas how this comes and to solve it?

thx
Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #1 on: 2006-01-21 18:56:11 »

requestFocus()

弾幕 ☆ @mahonnaiseblog
Offline Grand Poeba

Full Member
**

Posts: 143



« Reply #2 on: 2006-01-21 19:37:49 »

requestFocus()

tried it but didnt help (i dont have to it when just using jframe)
even tried requestFocusInWindow
Games published by our own members! Go get 'em!
Offline swpalmer

JGO Kernel
*****

Posts: 3438
Medals: 4


Where's the Kaboom?


« Reply #3 on: 2006-01-22 23:24:02 »

setFocusable(true); ?

Offline Mr_Light

JGO Strike Force
***

Posts: 893


shiny.


« Reply #4 on: 2006-01-23 10:52:25 »

whats the JDialog's owner?

this is one of the few uses where one should use requestFocus() over requestFocusInWindow(), make sure that setVisible(true); is called,and executed before the requestFocus();

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Grand Poeba

Full Member
**

Posts: 143



« Reply #5 on: 2006-01-23 12:07:46 »

whats the JDialog's owner?

this is one of the few uses where one should use requestFocus() over requestFocusInWindow(), make sure that setVisible(true); is called,and executed before the requestFocus();

the jdialog has no owner because its just appearing before the actual launch of the game. So no jframe has been created yet
Offline cylab

JGO Kernel
*****

Posts: 1940
Medals: 27



« Reply #6 on: 2006-01-24 03:03:28 »

I think the only way to overcome this problem is by creating the frame first, show it with a placeholder panel inside, display the dialog with this frame as the owner and modify the existing frame after the dialog exits.

Mathias - I Know What [you] Did Last Summer!
Offline Jeff

JGO Kernel
*****

Posts: 3535


Got any cats?


« Reply #7 on: 2006-01-29 19:56:13 »

if requestFocus on the window doesnt work, try it on the window's content pane.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.1 seconds with 20 queries.