need help with design to separate model and gui code?
model class = logic code
gui class = gui code
les say i have 3 classes.


Code:
  Main.java
    BoxGui.java
    BoxModel.java

Code:
 public classBoxModel
    {
        BoxGui bg = new BoxGui();
     
        public void moveBox(){
            int x = bg.getX();
            bg.setX(x+1);
        }
    }
Code:
 public class BoxGui
    {
        int x,y,width,height;
        public void paint(Graphics g){
            g.drawRect(x, y, width, height);
        }
    }

Code:
  public class Main{
        BoxModel bm = new BoxModel();
         BoxGui bg = new BoxGui();
        ...
         public void paintComponent(Graphics g) {
             bm.moveBox();
         }
         ...
         
          public void paint(Graphics g){
              bg.paint(g);
          }
    }


I guess i dont understand which class should have which class object. for ex:
in main do we create BoxModel or BoxGui or both obj?
in BoxModel do we need to create BoxGui obj?
in BoxGui do we need to create BoxModel obj?