From cfdbc6046185d372f4c7060c737fd34cecce1d1a Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Sat, 21 Jan 2023 12:09:03 +0100 Subject: [PATCH] Setup Panel with label nr 3 --- src/main/java/src/MainFrame.java | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/src/MainFrame.java b/src/main/java/src/MainFrame.java index 405ff81..973ad23 100644 --- a/src/main/java/src/MainFrame.java +++ b/src/main/java/src/MainFrame.java @@ -5,9 +5,13 @@ import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; public class MainFrame extends JFrame { + private GameField gameField; + public void run() { this.setLayout(null); @@ -28,7 +32,7 @@ public class MainFrame extends JFrame { header.setBounds(125, 5, 250, 50); rootPanel.add(header); - GameField gameField = new GameField(360); + gameField = new GameField(360); gameField.setBounds(70, 50, 360, 360); rootPanel.add(gameField); @@ -42,9 +46,14 @@ public class MainFrame extends JFrame { JPanel jPanel1 = setupNums("1"); boxPanel.add(jPanel1); + JPanel jPanel2 = setupNums("2"); boxPanel.add(jPanel2); + JPanel jPanel3 = setupNums("3"); + boxPanel.add(jPanel3); + + JButton back = new JButton(); back.setVisible(true); back.setBounds(5, 5, 100, 25); @@ -76,7 +85,33 @@ public class MainFrame extends JFrame { jPanel.setBackground(Color.BLUE); jPanel.setVisible(true); jPanel.setBorder(new LineBorder(Color.PINK, 1)); + jPanel.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + gameField.getActivePanel().setValue(Integer.valueOf(number)); + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); JLabel numLabel1 = new JLabel(); numLabel1.setText(number); numLabel1.setLayout(null);