I want to create a java application where you can build simple logic circuits (just started learning java recently and it was just a random project idea I got off the net)
Ultimately I want the gates as icons on a pane that users can drag and drop onto a canvas but drag and drop is a bit too far ahead for now.
So I was thinking of a list next to a large white area (a panel or a canvas) and clicking on the canvas or panel should create a new instance of whatever is selected on the list. AND gate, OR gate, etc.
I made the gates by subclassing JLabel (each type of gate is a class) and setting a gif of the gate as the icon in the constructor. I also added code to handle two connections (to be used later when I connect gates on the canvas with lines) and to calculate the truth value of the connections through the gate.
The part I'm stuck on now
How can I add gates on click to a panel (or should I use a canvas) at the location of the click? Also how can I make the label movable after it's been created? If that involves drag and drop I can forget that for now, but the main problem is dynamically instantiating a class at the point of click on the panel. The class is a JLabel subclass.