954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Move jframe

how to move a jframe which has no taskbar?

frame.addmousemotionlistener(this);

public void mousedragged(MouseEvent e)
{
   // What to write here
}


I tried setBounds of jframe but it flicker when we try to move the frame.

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

try... frame.setLocation (x, y);

hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 248
Solved Threads: 105
 

@Majestics

I really can't ...(better ask question in all your cases), not sure if with mouse or as suggested @hfx642 ???

both ways are pretty simple,

you must waiting for some of profesional, because your last waiting moved you wrong way :-)

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

Sorry its title bar.... I am trying different codes , some are working but really slow. I will post the code which suit best for this situation, if i get it before professionals... :)

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

Top-Level Comtainers without TaskBar is or isn't undecorated ???

if yes then you have put there JPanel and there you can add MouseListener extends MouseAdapter

finally there isn't better and clear as http://tips4java.wordpress.com/2009/06/14/moving-windows/

never ever mixing Component Mover and Resizer or use that in same time, witout deepest knowledge about Listener and SubSystem events

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

I recently posted a little sample for moving a Swing component with a mouse here
http://www.daniweb.com/software-development/java/threads/375002
it drags a JLabel in a JFrame, but the original version used to drag an undecorated window around the screen. You should be able to use it with almost zero changes.
J

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

try this

frame.addmousemotionlistener(this);
public void mousedragged(MouseEvent e)
{
   frame.setLocation(frame.getX()+e.getX(),frame.getY()+e.getY());
}
Kyberium
Newbie Poster
1 post since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You