How to add button to LoginState

Hi guys working on a login system on a 2d rpg game.

Basically we have a state manager,menu state,login state etc…

im trying to add JButton and JTextbox to one of this states but i couldnt do that.

First this is display class:


import java.awt.Canvas;


import java.awt.Dimension;

import javax.swing.JFrame;

public class Display {

	private JFrame frame;
	private Canvas canvas;
	
	private String title;
	private int width,height;
	
	public Display(String title,int width,int height){
		this.title = title;
		this.width=width;
		this.height=height;
		createDisplay();
		
	}
	private void createDisplay(){
		frame = new JFrame(title);
		frame.setSize(width, height);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		canvas = new Canvas();//initilize.
		canvas.setPreferredSize(new Dimension(width,height));
		canvas.setMaximumSize(new Dimension(width,height));
		canvas.setMinimumSize(new Dimension(width,height));
		canvas.setFocusable(false);///!!! key calissin diyee.focusla ilgili.
		frame.add(canvas);
		frame.pack();

	}
	public Canvas getCanvas(){ //getter
		return canvas;
	}
	public JFrame getFrame(){
		return frame;
	}
	
	
}

This is the login state.I want to add Jbutton and textbox to this state.


import java.awt.Graphics;

public class LoginState extends State {
	private UIManager uiManager;

	public LoginState(final Handler handler) {
		super(handler);
		uiManager = new UIManager(handler);

		uiManager.addObject(new UIImageButton(200, 200, 400, 64, Assets.btn_start, new ClickListener() {
			@Override
			public void onClick() {
				handler.getMouseManager().setUIManager(uiManager);
				State.setState(handler.getGame().gameState);
			}
		}));

	}

	
	public void tick() {
		uiManager.tick();
		handler.getMouseManager().setUIManager(uiManager);
		State.setState(handler.getGame().LoginState);
		
	}

	@Override
	public void render(Graphics g) {
		uiManager.render(g);
	}
	
}

i tryed
display.getcanvas.add(button)
like that but its not working and actually i wonder how people add JButton or Jtextfields to their game states ? i can only add image buttons to canvas