Automatically draw cards?

The game I am working on consists of each player drawing three tiles at a time until the stack is depleted.

Here’s the way I was thinking of implementing this. My preference would be to have a right click option that sends 1 card from the main deck to stack 1, one to stack 2 and 1 to stack three. Now, because players can keep certain cards in hand, I want the program to automatically fill the empty decks. For instance, if stack one is not empty, a card is put into stack 2 and stack 3. If 1 and 3 are full, only stack 2 receives a card. Can somebody give me guidance on how to set this up. I am very new to mod creation and am still pretty lacking when it comes to java programming, so if somebody could give me a nice clear description of how to do this, I would really apreciate it.

Thank you.