Java Swing: resize Undecorated window

Hi, here is code snap to make resizable your undecorated window

private void _setUpWindowResizeEvent() {
this.addMouseMotionListener(
new MouseMotionListener() {

public void mouseDragged(MouseEvent mouseEvent) {
if( mHozResizeEnabled || mVerResizeEnabled ) {
int x = mouseEvent.getX();
int y = mouseEvent.getY();
_resizeWindow( MouseInfo.getPointerInfo().getLocation() );
}
}

public void mouseMoved(MouseEvent mouseEvent) {
boolean horizontalResize = mouseEvent.getX() = getWidth()-5;
boolean verticalResize = mouseEvent.getY() = getHeight()-5;

if( horizontalResize ) {
setCursor( new Cursor( Cursor.W_RESIZE_CURSOR ) );
mHozResizeEnabled = true;
mWindowMouseClickPoint = mouseEvent.getPoint();
}
else if( verticalResize ) {
setCursor( new Cursor( Cursor.S_RESIZE_CURSOR ) );
mVerResizeEnabled = true;
mWindowMouseClickPoint = mouseEvent.getPoint();
}
else {
setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
mHozResizeEnabled = false;
mVerResizeEnabled = false;
}

}
}
);
}

Advertisement

2 responses to “Java Swing: resize Undecorated window

  1. roger

    testing the ajax

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

my tweets

 

September 2006
S S M T W T F
« Aug   Oct »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Flickr Photos



@kamalapur over bridge

@kamalapur station

cox's bazaar trip oct 09

cox's bazaar trip oct 09

More Photos
Follow

Get every new post delivered to your Inbox.