import javax.swing.*; import java.awt.*; public class LoginScreen extends JComponent { private Image login; public LoginScreen() { super(); this.login = Toolkit.getDefaultToolkit().getImage("login.jpg"); } @Override protected void paintComponent(Graphics brush) { Graphics newBrush = brush.create(); if (this.isOpaque()) { newBrush.setColor(this.getBackground()); newBrush.fillRect(0, 0, this.getWidth(), this.getHeight()); } newBrush.drawImage(this.login, 0, 0, this); } }