Reputation: 14049
I would like to have a Java component which has a resize icon on the bottom right of the component so that when I drag that icon, the component will automatically resize with it.
By resize icon, I mean the following:
The above image contains the resize icon in the Google Talk messenger's main window. Is there any Java component which provides this facility?
Upvotes: 1
Views: 1779
Reputation: 1329092
You will find in this article how to add an icon looking like the resize icon you are referring to.
Upvotes: 1
Reputation:
ummm putting an image there is not hard... the resizing is. you'll want to use (once you have some sort of button) code like this:
private void buttonMousePressed(java.awt.event.MouseEvent evt) {
sx = evt.getX();
sy = evt.getY();
}
private void buttonMouseDragged(java.awt.event.MouseEvent evt) {
if(!evt.isMetaDown()){
Point p = getLocation();
locX = p.x + evt.getX()-sx;
locY = p.y + evt.getY()-sy;
setLocation(locX, locY);
}
}
...except instead of Setlocation you'll want to use something like setBounds or setSize... and you'll have to modify the code a bit. What I have is for dragging it, but the principle is the same.
Upvotes: 0