I want to create JWindow that I can resize with a mouse. Here is my code. Dragging is fairly easy, but i can't figure out how to resize it.
public class
Test extends JWindow implements MouseMotionListener,FocusListener
{
Point mousePointer;
public Test()
{
init();
setVisible(true);
}
public void init()
{
addMouseMotionListener(this);
setBounds(500, 500, 400, 400);
addFocusListener(this);
}
public void focusGained(FocusEvent aFocusEvent)
{
Point aPoint = getLocation();
setLocation(15000, 0);
setLocation(aPoint);
}
public void focusLost(FocusEvent aFocusEvent)
{
}
public void mouseDragged(MouseEvent aMouseEvent)
{
Point aPoint = aMouseEvent.getPoint();
int x = getX() + aPoint.x - mousePointer.x;
int y = getY() + aPoint.y - mousePointer.y;
setLocation(x, y);
Graphics graphics = getGraphics();
paint(graphics);
}
public void mouseClicked(MouseEvent me)
{
}
public void mouseMoved(MouseEvent aMouseEvent)
{
mousePointer = aMouseEvent.getPoint();
}
public void paint(Graphics graphics)
{
}
protected int getDefaultCursor(MouseEvent p_Evt)
{
return Cursor.DEFAULT_CURSOR;
}
public static void main(
String[] args)
{
new Test();
}
}