Mouse event lost

Hello, :smiley:
I use a frame full screen, which receive mouse events for the game.
The problem is that the frame is frequently not advised , and I lose many events before they can reach my code.
I work with W2000, with a WACOM mouse. I reduced the computing time to check if System was not overbooked, without success. :ā€™(

Has anybody had the same problem? Does anybody have a clue? ???

if you are losing them before they reach your code - how do you even know they exist int eh 1st place :wink:

seriously though, do you lose all events, or is it just mouse events?

iā€™ve found when using fullscreen, it is possible for the event dispatch thread to become dorment for no particular reason ???

I havnā€™t locked down the actual cause yet though :o

After cliking 20, only a range from 4 to 15 could reach my app.
Even if it is for a strategy game, it can make the player ā€¦ nervous.

hello.
I seem to have somewhat the same problems.
I have an application using j3d that sometimes does not receive buttonup or mouseup events. iā€™ll have to take time to investigate, but iā€™m thinking that events that occur during GC pauses are lost. (1.4.2 beta) this is new, i think. each time i get s slight pause or a glitch and i depress the keys at the same time, i donā€™t get the event.
Of course, it is not very predictible, and as soon as iā€™m convinced of the cause, iā€™ll try to make a test case, but i doubt iā€™d be able to create a special program to reveal this. each timeā€¦
Please check if the events you donā€™t receive occur during GC pauses (if you can see them)
By the way, what jdk release do you use?

What does GC mean?

I use 1.4.1_02.
I have tried to rise to max the priority of awt_event queue. It didnā€™t make any difference.
I wonder how many tasks are to be crossed between the mouse detection (by polling or IT ?) and the message sending to awt event queue.

GC is for Garbage Collector. Plus court, non ? ;D
Are you using 100 % of the cpu, and generating garbage? Do you get GC pauses?

As I have tried with just the fullscreen jframe (to remove any other incidence) and dispose of graphics object at the end of paint, garbage should be very small crumbles.

Any way, I have try to disable it by writing -Xnoclassgc into launcher application params in JBuilder. As I am new to this ID, I am not sure to have tested it properly. If I have done it properly, the result is not making any progress. Is there another way to disable GC ?

You canā€™t disable GC. You can only try to avoid creating too much garbage.

So whatā€™s garbage? - you may ask. Itā€™s the stuff you donā€™t need anymore.

In C/C++ and a lot of other languages you have to allocate and deallocate memory for yourself. Sounds like fun - but itā€™s a lot of work and usually it produces a lot of errors and so called ā€œmemory leaksā€ (if you forgot to delete/deallocate memory itā€™s marked as ā€œin useā€ and canā€™t be used till the next reboot).

In Jave deallocation is done automatically by the GC. Unfortunately the whole world is stopped as long as the GC has something to do.

The only thing wich helps a bit is avoiding garbage where itā€™s possible. You can create a ā€œpoolā€ of objects wich you reuse till the end of the program (Yes. Recycling avoids garbage ;)).

The GC kicks in every here and thenā€¦ if there is a lot to do it will take awhile and if thereā€™s nothing to do you wonā€™t even notice it.

Well the loosing of events sounds quite seriouslyā€¦ that shouldnā€™t happen ever :-/

can u post some sourcecode that has the problem with the lost mouse events so we can verify it to and try to nail down the problem

import javax.swing.JFrame;
import java.awt.;
import java.awt.event.
;

public class FullJFrame
extends JFrame {

public static void main(String[] args) {
FullJFrame MainFrame = new FullJFrame();
}

public FullJFrame() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
DisplayMode UsualDisplayMode = gd.getDisplayMode();

Rectangle GameScreen = new Rectangle(0, 0, UsualDisplayMode.getWidth(),
                                     UsualDisplayMode.getHeight());
this.setBounds(GameScreen);
setUndecorated(true);
if (gd.isFullScreenSupported()) {
  gd.setFullScreenWindow(this);
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.BLUE);

this.setVisible(true);

this.addMouseListener
    (new MouseAdapter() {
  public void mouseClicked(MouseEvent evt) {
    System.err.println('\n' + Thread.currentThread().getName() + ' ' +
                       String.valueOf(Thread.currentThread().getPriority()));
  }
});

this.addKeyListener(new KeyAdapter() {
  public void keyPressed(KeyEvent evt) {
    if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
      System.exit(0); //evt.getKeyCode()
    }
  }
});

}

}

I got 20 of 20 eventsā€¦

what JDK version are you using?

last official standard edition 1.4.1_02

I feel relieved . If it works better somewhere else, there maybe a solution. Which system are you using?

I have checked again.
It is effectively 20/20 if I donā€™t move between click, but it is still poor if I make some movements between each click 5-12/20.
How have you tested?

you are using mouseClicked.

mouseClicked events are only fired when the mouse is clicked and released at the same x,y position.

because you are moving while clicking, you are creating mousedragged events not mouseclciked.

use mousePressed/Released instead.

So goooood! Thatā€™s it !

You maybe know how to deiconify the program quoted above. It never reappears.

I know that there is a window event (windowDeiconified), I tried to put a paint call in it. But this event never occurs.

[quote]So goooood! Thatā€™s it !

You maybe know how to deiconify the program quoted above. It never reappears.

I know that there is a window event (windowDeiconified), I tried to put a paint call in it. But this event never occurs.
[/quote]
you mean alt+tab out (minimizing the window), then restore it?

That works just fine for me.

The fullscreen api is buggy, and its possible you may need to update your gfx drivers.