java - How to get a dot(or a very small circle) to center at the middle of a JFrame? -


i trying dot stay @ center of screen regardless of user move screen around, or resize screen using paint graphics or graphics2d.

thanks in advance

public void paint(graphics g) {     super.paint(g);     int x = getwidth() /2 ;     int y = getheight() / 2;     g.drawoval(x, y, 10, 10); } 

to make sure stays in middle time, add componentlistener jframe, this:

myjframe() {         addcomponentlistener(new componentadapter() {              @override             public void componentresized(componentevent e) {                 repaint();             }          }); } 

the componentlistener not needed....


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -