|
|
@ -1,9 +1,12 @@ |
|
|
|
package src; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
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 { |
|
|
|
|
|
|
@ -40,37 +43,187 @@ public class MainFrame extends JFrame { |
|
|
|
gameField.setBounds(70, 50, 360, 360); |
|
|
|
rootPanel.add(gameField); |
|
|
|
|
|
|
|
JPanel numberPanel = new JPanel(); |
|
|
|
numberPanel.setVisible(true); |
|
|
|
numberPanel.setBounds(100, 450, 300, 30); |
|
|
|
rootPanel.add(numberPanel); |
|
|
|
|
|
|
|
for (int i = 1, j=0; i < 10; i++) { |
|
|
|
JLabel numberi= new JLabel(); |
|
|
|
numberi.setText(""+i); |
|
|
|
numberi.setBounds(5+j, 5, 20, 20); |
|
|
|
numberPanel.setLayout(null); |
|
|
|
|
|
|
|
JPanel ni = new JPanel(); |
|
|
|
ni.setBounds(5+j, 5, 20, 20); |
|
|
|
ni.setVisible(true); |
|
|
|
ni.setBackground(Color.pink); |
|
|
|
ni.add(numberi); |
|
|
|
numberPanel.add(ni); |
|
|
|
j=j+25; |
|
|
|
} |
|
|
|
|
|
|
|
JLabel number10= new JLabel(); |
|
|
|
number10.setText(" "); |
|
|
|
number10.setBounds(250, 5, 20, 20); |
|
|
|
numberPanel.setLayout(null); |
|
|
|
|
|
|
|
JPanel n10 = new JPanel(); |
|
|
|
n10.setBounds(250, 5, 20, 20); |
|
|
|
n10.setVisible(true); |
|
|
|
n10.setBackground(Color.pink); |
|
|
|
n10.add(number10); |
|
|
|
numberPanel.add(n10); |
|
|
|
// JPanel numberPanel = new JPanel(); |
|
|
|
// numberPanel.setVisible(true); |
|
|
|
// numberPanel.setBounds(100, 450, 300, 30); |
|
|
|
// rootPanel.add(numberPanel); |
|
|
|
|
|
|
|
int j = 0; |
|
|
|
|
|
|
|
JPanel boxPanel = new JPanel(); |
|
|
|
boxPanel.setBounds(100, 450, 300, 30); |
|
|
|
boxPanel.setVisible(true); |
|
|
|
boxPanel.setBackground(Color.GREEN); |
|
|
|
boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.X_AXIS)); |
|
|
|
rootPanel.add(boxPanel); |
|
|
|
|
|
|
|
JPanel panel1 = new JPanel(); |
|
|
|
panel1.setBackground(Color.BLUE); |
|
|
|
panel1.setVisible(true); |
|
|
|
panel1.setBorder(new LineBorder(Color.PINK, 1)); |
|
|
|
boxPanel.add(panel1); |
|
|
|
boxPanel.add(Box.createHorizontalStrut(5)); |
|
|
|
panel1.addMouseListener(new MouseListener() { |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
if (gameField.getActivePanel() != null) { |
|
|
|
gameField.getActivePanel().setValue(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
JLabel numLabel1 = new JLabel(); |
|
|
|
numLabel1.setText("1"); |
|
|
|
numLabel1.setLayout(null); |
|
|
|
numLabel1.setVisible(true); |
|
|
|
panel1.add(numLabel1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel panel2 = new JPanel(); |
|
|
|
panel2.setBackground(Color.BLUE); |
|
|
|
panel2.setVisible(true); |
|
|
|
panel2.setBorder(new LineBorder(Color.PINK, 1)); |
|
|
|
boxPanel.add(panel2); |
|
|
|
boxPanel.add(Box.createHorizontalStrut(5)); |
|
|
|
|
|
|
|
JLabel numLabel2 = new JLabel(); |
|
|
|
numLabel2.setText("2"); |
|
|
|
numLabel2.setLayout(null); |
|
|
|
numLabel2.setVisible(true); |
|
|
|
panel2.add(numLabel2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 1, j=0; i < 10; i++) { |
|
|
|
// JLabel numberi= new JLabel(); |
|
|
|
// numberi.setText(""+i); |
|
|
|
// numberi.setBounds(5+j, 5, 20, 20); |
|
|
|
// numberPanel.setLayout(null); |
|
|
|
// numberi.addMouseListener(new MouseListener() { |
|
|
|
// @Override |
|
|
|
// public void mouseClicked(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mousePressed(MouseEvent e) { |
|
|
|
// Field activePanel = gameField.getActivePanel(); |
|
|
|
// System.out.println(); |
|
|
|
// activePanel.setValue(2); |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseReleased(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseEntered(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseExited(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// |
|
|
|
// JPanel ni = new JPanel(); |
|
|
|
// ni.setBounds(5+j, 5, 20, 20); |
|
|
|
// ni.setVisible(true); |
|
|
|
// ni.setBackground(Color.pink); |
|
|
|
// ni.add(numberi); |
|
|
|
// numberPanel.add(ni); |
|
|
|
// j=j+25; |
|
|
|
// ni.addMouseListener(new MouseListener() { |
|
|
|
// @Override |
|
|
|
// public void mouseClicked(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mousePressed(MouseEvent e) { |
|
|
|
// gameField.getActivePanel().setValue(1); |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseReleased(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseEntered(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseExited(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
|
|
|
|
// JLabel number10= new JLabel(); |
|
|
|
// number10.setText(" "); |
|
|
|
// number10.setBounds(250, 5, 20, 20); |
|
|
|
// numberPanel.setLayout(null); |
|
|
|
// number10.addMouseListener(new MouseListener() { |
|
|
|
// @Override |
|
|
|
// public void mouseClicked(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mousePressed(MouseEvent e) { |
|
|
|
// gameField.getActiveLabel().setVisible(true); |
|
|
|
// gameField.getActiveLabel().setText("10"); |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseReleased(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseEntered(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// @Override |
|
|
|
// public void mouseExited(MouseEvent e) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// |
|
|
|
// JPanel n10 = new JPanel(); |
|
|
|
// n10.setBounds(250, 5, 20, 20); |
|
|
|
// n10.setVisible(true); |
|
|
|
// n10.setBackground(Color.pink); |
|
|
|
// n10.add(number10); |
|
|
|
// numberPanel.add(n10); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|