You are on page 1of 2

setMenuBar(menuBar);

addWindowListener(new WindowAdapter() {

@Override

public void windowClosing (WindowEvent e) {

System.exit(0);

});

createSystem();

private void createSystem() {

Panel mainSystem = new Panel();

mainSystem.setBackground(GRAY);

mainSystem.setBounds(0, 100, width, height / 2);

mainSystem.add(Box.createRigidArea(new Dimension(0, 200))); // Căn trái 0, trên 200

mainSystem.setLayout(new FlowLayout(FlowLayout.CENTER));

ImageIcon img = new ImageIcon("icon.jpg");

Image scaledImg = img.getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH);

Color[] color = {new Color(255, 0, 0), Color.BLUE, Color.YELLOW, Color.GREEN};

CreateButton button[] = new CreateButton[4];

for (int i = 0; i < 4; i++) {

button[i] = new CreateButton(String.valueOf(i + 1), new ImageIcon(scaledImg), color[i]);

mainSystem.add(button[i]);

}
Button bt2 = new Button("2");

Button bt3 = new Button("3");

Button bt4 = new Button("4");

bt2.setBackground(YELLOW);

bt3.setBackground(GREEN);

bt4.setBackground(GRAY);

add(mainSystem);

public static void main(String[] args) {

new Menu_Enter_Name_YesNo_Dialog().setVisible(true);

You might also like