Click here to Skip to main content
15,920,217 members
Home / Discussions / Java
   

Java

 
GeneralRe: Help With Sorting Multidimensional String Array Pin
Richard MacCutchan24-Nov-19 23:14
mveRichard MacCutchan24-Nov-19 23:14 
QuestionJavaFX Background not beeing used on a ScrollPane element [Solved] Pin
Valentinor24-Nov-19 4:48
Valentinor24-Nov-19 4:48 
AnswerSolution Pin
Valentinor27-Nov-19 6:40
Valentinor27-Nov-19 6:40 
Question!!Please Help!! Student Needs Help It Shows me exercise/ wrong catagory moved to web dev JS Pin
Member 1465076510-Nov-19 6:04
Member 1465076510-Nov-19 6:04 
QuestionRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Richard MacCutchan10-Nov-19 6:24
mveRichard MacCutchan10-Nov-19 6:24 
AnswerRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Member 1465076510-Nov-19 11:15
Member 1465076510-Nov-19 11:15 
AnswerRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined Pin
Member 1465076510-Nov-19 12:03
Member 1465076510-Nov-19 12:03 
QuestionGlobal Histogram Implementation in Java Pin
Member 146130164-Oct-19 11:37
Member 146130164-Oct-19 11:37 
AnswerRe: Global Histogram Implementation in Java Pin
phil.o4-Oct-19 22:06
professionalphil.o4-Oct-19 22:06 
QuestionBiometric attendace machine data Pin
Member 146125164-Oct-19 1:15
Member 146125164-Oct-19 1:15 
AnswerRe: Biometric attendace machine data Pin
Richard MacCutchan4-Oct-19 3:19
mveRichard MacCutchan4-Oct-19 3:19 
AnswerRe: Biometric attendace machine data Pin
Gerry Schmitz4-Oct-19 6:35
mveGerry Schmitz4-Oct-19 6:35 
QuestionNeed to develop a program on Java for desktop Pin
Ryder Weber1-Oct-19 3:32
Ryder Weber1-Oct-19 3:32 
AnswerRe: Need to develop a program on Java for desktop Pin
Richard MacCutchan1-Oct-19 4:13
mveRichard MacCutchan1-Oct-19 4:13 
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 

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.