Click here to Skip to main content
15,891,372 members
Home / Discussions / Java
   

Java

 
AnswerRe: Need to develop a program on Java for desktop Pin
Gerry Schmitz4-Oct-19 20:35
mveGerry Schmitz4-Oct-19 20:35 
Questionhow to reuse open browser in java selenium? Pin
nadavrock29-Sep-19 19:23
nadavrock29-Sep-19 19:23 
AnswerRe: how to reuse open browser in java selenium? Pin
Leanbridge Technologies1-Nov-19 23:07
professionalLeanbridge Technologies1-Nov-19 23:07 
QuestionJava Cant pass the value that user input as the string and view it Pin
raigen27-Sep-19 5:44
raigen27-Sep-19 5:44 
AnswerRe: Java Cant pass the value that user input as the string and view it Pin
Richard MacCutchan27-Sep-19 6:56
mveRichard MacCutchan27-Sep-19 6:56 
GeneralRe: Java Cant pass the value that user input as the string and view it Pin
raigen27-Sep-19 14:52
raigen27-Sep-19 14:52 
GeneralRe: Java Cant pass the value that user input as the string and view it Pin
Richard MacCutchan27-Sep-19 21:48
mveRichard MacCutchan27-Sep-19 21:48 
QuestionJava Swing app dragging and dropping components with snapping Pin
Member 1457730716-Sep-19 5:27
Member 1457730716-Sep-19 5:27 
I'm working on a Java Swing application that will allow users to add index cards to a virtual corkboard. One of the big functionalities I want is for the user to be able to drag and drop cards to reorder them. I don't want to simply position cards at the exact X and Y mouse coordinates where the user releases the mouse button, getting that to work would be relatively trivial. I want the cards to "snap" into place, in a FlowLayout.

Problem is I'm not sure how to accomplish that with the typical MouseListener and MouseMotionListener. Right now my code is organized into a sort of MVC architecture. Here is my code on Github. Everything is just being committed to master for now.

I'm working with a sort of loose MVC type architecture. I have a MainController that has all other child controllers as it's properties. All the other child controllers also take the MainController instance in their constructors. The MainController basically controls the main JFrame of the app and the menu bar. It also acts as a hook for all of the other controllers to communicate with each other.

The ProjectController controls mouse and key events on the "corkboard" area.

The AddCardController is pretty simple, just controls the Add a card window.

Here's where it gets tricky:
The CardController controls mouse events on a particular card. Each card has an instance of the Card model, and it's own CardController, and it's own CardTemplate in the views folder. So every card the user creates is basically an instance of CardController. All the CardControllers are stored in an ArrayList on the MainController. And because every card on the board has it's own CardController, the EditCardController is created inside CardController, so those two are tied together.

This kind of works okay, but I have no idea how to get drag and drop with snapping to work with this architecture (or any architecture for that matter). Each CardTemplate -which is kind of just a component, it extends JPanel but I put it in the views folder for some reason (probably need to change that)- has it's CardController as it's MouseListener.

Can anyone give me advice on how to organize my code so that I can do dragging and dropping with snapping? Should I even hope to use a MouseListener or MouseMotionListener for this?
AnswerRe: Java Swing app dragging and dropping components with snapping Pin
Richard MacCutchan16-Sep-19 6:22
mveRichard MacCutchan16-Sep-19 6:22 
GeneralWhich language is best for developing sms api java Or .net ? Pin
Msg Club3-Sep-19 22:30
Msg Club3-Sep-19 22:30 
GeneralRe: Which language is best for developing sms api java Or .net ? Pin
OriginalGriff3-Sep-19 22:40
mveOriginalGriff3-Sep-19 22:40 
GeneralRe: Which language is best for developing sms api java Or .net ? Pin
MadMyche10-Sep-19 8:16
professionalMadMyche10-Sep-19 8:16 
GeneralRe: Which language is best for developing sms api java Or .net ? Pin
Wishe199129-Sep-19 23:27
Wishe199129-Sep-19 23:27 
GeneralRe: Which language is best for developing sms api java Or .net ? Pin
ReolusTechnologies12-Nov-19 3:08
professionalReolusTechnologies12-Nov-19 3:08 
QuestionRestaurant Reservation java code Pin
Member 1456547721-Aug-19 22:12
Member 1456547721-Aug-19 22:12 
AnswerRe: Restaurant Reservation java code Pin
Richard MacCutchan21-Aug-19 22:18
mveRichard MacCutchan21-Aug-19 22:18 
QuestionRecommendation: Learn from GITHUB project Pin
Anisul Huq7-Aug-19 18:20
Anisul Huq7-Aug-19 18:20 
AnswerRe: Recommendation: Learn from GITHUB project Pin
Richard MacCutchan7-Aug-19 22:04
mveRichard MacCutchan7-Aug-19 22:04 
AnswerRe: Recommendation: Learn from GITHUB project Pin
Wishe199129-Sep-19 23:29
Wishe199129-Sep-19 23:29 
QuestionLearning from GITHUB projects Pin
Anisul Huq6-Aug-19 13:13
Anisul Huq6-Aug-19 13:13 
Questionhow to use class for sending notification in android? Pin
Member 145520336-Aug-19 2:53
Member 145520336-Aug-19 2:53 
QuestionMy Simple servlet is called twice, i dont know why. Pin
yinallier15-Aug-19 20:27
yinallier15-Aug-19 20:27 
AnswerRe: My Simple servlet is called twice, i dont know why. Pin
Gerry Schmitz6-Aug-19 5:50
mveGerry Schmitz6-Aug-19 5:50 
QuestionMessage Removed Pin
2-Aug-19 23:03
Valentinor2-Aug-19 23:03 
QuestionJava Derby Database Pin
Gregory Guy30-Jul-19 20:16
Gregory Guy30-Jul-19 20:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.