Drag undecorated jDialog
draggable, java, jdialog, jframe, swing
Solution
Well, as @mKorbel suggested, I headed to here where I found a nice class called `ComponentMover` which helped me to do this. I'll need 2 more reputation so I saved the link to get back and upvote when I'm able to do it.
I'll have to ensure it works perfect and exactly in the way I want, but looks great! Thanks!
Problem
So, I have a jFrame in which I'm building the main interface window of a chat. This window/jFrame has several buttons , each of which show a jDialog (Which I created previously in Netbeans dragging a jDialog onto the parent(?) jFrame). My problem is that both windows are set to `undecorated = true` and so I wish to let the user drag and move all windows at will by clicking and dragging a portion of the windows (Which emulate the title bar when not undecorated) In all the jFrames I have accomplished this by the following code just after `initComponents()`: ``` final Point point = new Point(0,0); // Why 'final' and not simply Point point? addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if(!e.isMetaDown()){ point.x = e.getX(); point.y = e.getY(); System.out.println("Ratón pulsado: " + point.x + "," + point.y); } } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if(!e.isMetaDown() && point.y <= 17){ //Coordinates of title bar, any X and up to 17px from the top border Point p = getLocation(); setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y); System.out.println("Ratón movido: " + (p.x + e.getX() - point.x) + "," + (p.y + e.getY() - point.y)); } } }); ``` However, I don't know how to use this code in the jDialog. When I right click it in the Navigator, and select Customize code, then I can't paste it in there because the whole jFrame stops working. I'm new in this thing of jDialogs children of jFrames, so please help me with some guidelines :) Thanks