aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes need to create a resizable JWindow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "need to create a resizable JWindow" Watch "need to create a resizable JWindow" New topic
Author

need to create a resizable JWindow

John Smith
Greenhorn

Joined: Oct 07, 2003
Posts: 15
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();
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need to create a resizable JWindow