Fullscreen Questions

P

Peter Pfeiffer

Hello,
I have run a demo that goes into fullscreen mode, draws some lines and
then reverts back to the former mode. I tried to modify the sample code
to receive mouse clicks and keystrokes, so it would stop the drawing and
revert back. The key events do not seem to be received at all, and the
mouse events register, but the code within the mouseClicked method is
not run.

I have read that for the Mac the fullscreen mode is broken, but was
hoping to have just enough functionality available to do some simple
demo's. It also behaves the same way on Windows.

Any clues would be appreciated. Does anyone have any links for FAQ's or
discussions about Fullscreen mode? My google search wasn't very helpful.

Thanks,


pj . . .
 
A

Andrew Thompson

I have run a demo that goes into fullscreen mode, draws some lines and
then reverts back to the former mode.

Code?
I tried to modify the sample code to receive mouse clicks
and keystrokes, so it would stop the drawing and revert back.
The key events do not seem to be received at all, and the
mouse events register, but the code within the mouseClicked
method is not run.

" ?

The Screensavers of the SaverBeans* project use a full
screen mode window and exit on key or mouse events.
Maybe you can get some tips from that..

*<https://jdic.dev.java.net/documentation/incubator/screensaver/index.html>

OTOH, if your supply your code, maybe somebody can
spot the problem. A lost of people will not look at
code that does not compile, but please keep it short.
 
R

Roedy Green

I have read that for the Mac the fullscreen mode is broken, but was
hoping to have just enough functionality available to do some simple
demo's. It also behaves the same way on Windows.

First of all try bigscreen mode vs fullscreen. Make sure it works in
bigscreen. You may be tying up the AWT or Swing thread so that it
never gets a chance to service the keystroke or mouse events.
see http://mindprod.com/jgloss/paint.html

One other thing to try, is give some component explicit focus just
after you go to fullscreen. Perhaps under some conditions there is no
focus to receive the events or the events are going somewhere
unexpected.
 
P

Peter Pfeiffer

Thanks All for the replies.

Andrew said:

Spent some time looking at their source. While it is difficult to say
definitely, I can only see code for exiting via mouse listening events
and not key events. As Roedy points out, I should see if the thread is
tied up, etc.
OTOH, if your supply your code, maybe somebody can
spot the problem. A lost of people will not look at
code that does not compile, but please keep it short.
My code compiles, but the fullscreen code is modified from a textbook
example. If i can't make progress, I'll clean it up for inspection.


-- -- --- --- -- -- - -

Roedy said:
First of all try bigscreen mode vs fullscreen. Make sure it works in
bigscreen. You may be tying up the AWT or Swing thread so that it
never gets a chance to service the keystroke or mouse events.
see http://mindprod.com/jgloss/paint.html
Couldn't find "bigscreen" mode, but will try a normal JFrame for the
test. I do see a mouse clicked event on the log (if i do not dispose of
the Fullscreen frame) but it appears only after the return from full
screen mode. Maybe I'm not able to interrupt the drawing loop.


One other thing to try, is give some component explicit focus just
after you go to fullscreen. Perhaps under some conditions there is no
focus to receive the events or the events are going somewhere
unexpected.

Possible: I'm not experienced in tracking events and focused components.


thanks again,

pj . . .
 
A

Andrew Thompson

Thanks All for the replies.



Spent some time looking at their source.

Try one of the installers if you are not convinced.
..While it is difficult to say
definitely, I can only see code for exiting via mouse listening events
and not key events.

The savers always exited on key event, but I submitted a patch
to ensure the exit on mouse event. But..
As Roedy points out, I should see if the thread is
tied up, etc.

I think it's much more likely that your component does
not have focus (as Roedy suggested).
 
P

Peter Pfeiffer

Pasted below is the while loop that draws the lines. This is from a
textbook. When I comment it out, the key and mouse event listeners
respond OK as coded. Is there any thing in this code that prevents the
events from getting processed? Is it just an uninterruptible process?

thanks - pj . . .
 
R

Roedy Green

g.drawLine(counter-1, (counter-1)*5, bounds.width, bounds.height);

If at all possible, you want a way to figure out quickly which of your
lines you really need to draw by looking at the ClipBounds.

// With AWT no need to call super.paint(); update has already cleared
the screen.
// avoid rendering before or after the clip region.
// Normally we only render a 4 pixel high band at a time.
Rectangle r = g.getClipBounds();
 
P

Patricia Shanahan

Roedy said:
Never put the AWT or Swing thread to sleep. It can't do any uselful
work while asleep, just like a human.

Also, the while(!done()) loop must not be run in the event handling
thread if done() depends on incoming events. That could cause a deadlock.

Patricia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top