Drag « JPanel « Java Swing Q&A





1. Dragging JPanel    stackoverflow.com

I've got a problem when trying to drag a JPanel. If I implement it purely in MouseDragged as:

public void mouseDragged(MouseEvent me) {
   me.getSource().setLocation(me.getX(), me.getY());
}
I get a weird effect of ...

2. Drag Image in swing in netbeans without code    stackoverflow.com

I am creating a swing application. My requirnment is that I have to drag an image in my jpanel(not using code). But, in palette, I didn't find any useful option to do this.... So, ...

3. help dragging a jpanel please...    coderanch.com

i finally got my jpanel to be draggable. my problem is when i click inside the panel to drag it, the panel's x,y start point jumps to my cursor .... i can only drag the panel from the upper left corner. (if i click in the middle of the panel, the entire panel jumps over to where my cursor is on ...

4. Automatically resizing JPanels when JFrame is resized by dragging.    coderanch.com

import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JPanel; public class Main extends JFrame { JPanel red = new ColorPanel(Color.red,300,300); JPanel grn = new ColorPanel(Color.green,100,300); public Main() { RelativeLayout rl = new RelativeLayout(RelativeLayout.X_AXIS, 10); JPanel panel = new JPanel( rl ); panel.add(red, new Float(1)); panel.add(grn); this.getContentPane().add(panel); this.setVisible(true); this.pack(); } public static void main(String[] args) { new Main(); } } class ColorPanel extends ...

5. Problem in dragging Panel    coderanch.com

Hi, i have added few taskpanes to a ScrollablePanel, like: private JPanel content = new ScrollablePanel(); content.add(taskpane1, "0, "+0); content.add(taskpane2, "0, "+2); Now the problem iam facing is that: when i click on the edge of the scrollpane (not the scrollbar, but the edge), it is directly expanding to the right with a certain width, without allowing me to drag it ...

6. Help with drag from panel    java-forums.org

Well actually, I found a solution to this already.. I make a Jlabel and add the mouse motion and drop listeners, then it the drop listener is fired and is found to be in a target (in this case another panel), I create a jlabel at runtime and place it in the other panel.. The only thing left is the ability ...

7. Swing - two JPanels divided by a draggable dividing bar?    forums.oracle.com

I'd like to create two JPanels next to each other, with a small divider between them that a user could drag left or right to make the right JPanel larger and the left smaller or vice-versa. I don't even know where to begin with this... have any of you implemented something like this in the past? I'm not asking for anyone ...