Traffic simulator – graphics [Java]

Hi, I need your help with my project. I'm doing traffic simulator, but I don't want it to be static map with moving cars, I want it to have methods to generate the roads with intersection (for now I have few simplifications like the roads are straight vertical or horizontal lanes, for now there is also no roundabouts and priority on road - on each intersection are the traffic lights). I started to code it, but quickly I noticed, that easier way will be first do the graphic (I need just an easy one) and then deal with things like counting cars on intersection, more sophisticated collision system or lane change, and here I have a few questions, and I will be glad for any answer:

  • I found the Model–view–controller pattern and as I understand, I should make separated class for graphics, to not have everything in one place, but how the graphic class and the controlling class shoiuld comunicate? For example I have class Car with position (x,y) and all staff to respectively change it. I have also class CarGraphics with paint methot, so would it work if the paint method would be static and get car as argument?

  • I have also problem with understanding all graphics methods. As I think for now, the app window will be generated with JFrame class, but I don't want the road to take whole window. What type should have the road, so I could for example set background as green rectangle, draw lines as lanes, and draw small rectangles as cars in it? I would very much like to place all things with reference to corner of the background, not to the corner of whole window. I basicly need a hint on type of components which could work as like I have class RoadGraphics wchich includes window 900x600 on witch I draw background, lanes, traffic lightts and cars and then place this whole thing in main frame.

For now I deal with the backend (I just did a few simple things, I must also admit I'm quite new in Java and it is my first serious project) and I think it will be easier if I will be able to see moving and responsive objects than just catch exeptions and do a lot of if statements, so I will be really glad for any sugestions and answers.

Join tables to display activity

Hello i have a database which users make groups or send messages to other registered, in our project, users. So you have messages as M,users as U, groups as G. So you want to show all updates that happen in these tables WHERE (uid - thats the user id column on U table.). All tables have CREATED as datetime column. Users yable is uid on messages is uid_fk and to groups uid_fk. Can i do that with a single statement or do i need to do anything else?