java - Drag and move JPanels in a group of JPanels -


there group of 10 jpanels placed in gridlayout. want drag 1 jpanel(for instance panel1) , place on jpanel (for instance panel2) , move panel2 left or right , place panel1 in panel2 position. able drag jpanel using drag option, not able drop @ required position. need in moving panels in drop location. sorry, if question not clear. hope understand. in advance.

you try this, said, there's better way:

public jpanel getpanelcolliding(jpanel dragpanel, jpanel[] panels) {    rectangle rdrag = dragpanel.getbounds();     (jpanel panel : panels){      if (panel == dragpanel) continue;       rectangle r = panel.getbounds();      if (r.insersects(rdrag))          return r;    }     return null; } 

then in drag listener can call , swap panel locations if getpanelcolliding() not null. didn't test this, should work!


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -