Thanks to code-ranchers for helping me from last complete year so i just pretending as java programmer, in following reference if any one need to all history.
questions-JPanel & many more...
Now i implement all this concept in one big project as small facility of draggable small jpanels within big jpanel which inside JDialog.
Scenario of question:-
Database in mysql, connectivity via hibernate,jdbc 2 java classes
one as following:-
2nd one as follows:-
Problem scenario:- i initialize small panels in one class & add in array(almost more than 1000) within another class(which created by help of database) & there i put them by formula as whenever i start application all should place as per that.
after staring application any small panel i pick by mousepress & drag it here & there (but not deliberately bad position), when i mouse release then that particular panel place there.
now i want to create array of integers which keep small panels default x,y which set in class currentstatus. & those array should read/write in class smallpanel where class Dragger use it. & vice versa. means any small panels old_x, old_y i should read by class currentstatus & new_x, new_y from class Dragger.
question:- 1. How should i do all this thing?
Please any clue or way...i think its very basic but i forgot by never use after studding in school...
Millions saw the apple fall, but Newton asked why.
If you understand, say "understand". If you don't understand, say "don't understand". But if you understand and say "don't understand". How do I understand that you understand? Understand!
not sure I understand the question, but if I remember correctly from past threads,
each panel's x,y are read in from a db, then if a panel is dragged, in mouseReleased
a check is made of its current location to see if it overlaps another panel, or is outside
the frame, and if so, its location is adjusted to a 'legal' location.
if your question is about saving the new location x,y one way would be to use the
panel's name property - use the panel's array identifier as its name (name is a string which you later convert to int). so, when (in mouseReleased) the dragged panel settles
in a 'legal' position, you update the array by
where you save the new/current x,y
Joined: Sep 11, 2007
Thanks for replies,
Kemal Sokolovic wrote:please correct code indentation so your source will be more pleasant to read. That way you increase your chances of getting a better answer.
I edited my first post, now i can think so that code is more pleasant with compare to previous.
Paul Clapham wrote:
You think that drag-and-drop is "very basic"? Well, it isn't really. It's rather complicated.
You are right sir, my sentence is not for drag-drop functionality, it written for array of integer can read write from one class to another class. I think it is very simple for java programmer but hard to java pretenders like me.
Michael Dunn wrote:
not sure I understand the question,....
Yes in last thread i manage to save,update x, y co-ordinate in table which in mysql by jdbc or hibernate. Its trial small program.
But now in this big project its more complicated for do this in existing tables, existing db result lists. lots of limitations.
I am trying to do take array of x,y from one class where all(array) small jpanel's location set, & put in class where actual jpanel(only one) written, so i can check overlapping of jpanels without db.
I also tried your code for avoid overlapping which you give me in june in same forum. but that technique not understand by me. I am trying more easy & basic way.
I am trying to create 2 rectangles one by default co-ordinates & second by new co-ordinates, if both intersects then overlapping if not then overlapping not.
(In this process my sub question is :- i confuse in intersects & intersection! :-( ).