|
@ -21,9 +21,21 @@ public class MouseGame extends JFrame { |
|
|
private JPanel contentPane; |
|
|
private JPanel contentPane; |
|
|
public Robot robot = new Robot(); |
|
|
public Robot robot = new Robot(); |
|
|
|
|
|
|
|
|
|
|
|
public Color paneFarbeBackground = new Color(128, 128, 128); |
|
|
|
|
|
public Color paneFarbeForeground = new Color(0, 0, 0); |
|
|
|
|
|
|
|
|
|
|
|
public Color panelRahmenFarbeBackground = new Color(0, 0, 0); |
|
|
|
|
|
|
|
|
|
|
|
public Font fontTahoma = new Font("Tahoma", Font.BOLD, 30); |
|
|
|
|
|
|
|
|
int resetX = 200; |
|
|
int resetX = 200; |
|
|
int resetY = 170; |
|
|
int resetY = 170; |
|
|
|
|
|
|
|
|
|
|
|
int breiteFrame = 900; |
|
|
|
|
|
int hoeheFrame = 650; |
|
|
|
|
|
|
|
|
|
|
|
int breitePanel = 696; |
|
|
|
|
|
int hoehePanel = 569; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Launch the application. |
|
|
* Launch the application. |
|
@ -47,7 +59,7 @@ public class MouseGame extends JFrame { |
|
|
|
|
|
|
|
|
//Fensterrahmen Haupt Layout |
|
|
//Fensterrahmen Haupt Layout |
|
|
setTitle("Mouse Game"); |
|
|
setTitle("Mouse Game"); |
|
|
setBounds(100, 100, 900, 650); |
|
|
|
|
|
|
|
|
setBounds(100, 100, breiteFrame, hoeheFrame); |
|
|
robot.mouseMove(resetX, resetY); |
|
|
robot.mouseMove(resetX, resetY); |
|
|
|
|
|
|
|
|
contentPane = new JPanel(); |
|
|
contentPane = new JPanel(); |
|
@ -57,49 +69,49 @@ public class MouseGame extends JFrame { |
|
|
|
|
|
|
|
|
setForeground(Color.GRAY); |
|
|
setForeground(Color.GRAY); |
|
|
setBackground(Color.DARK_GRAY); |
|
|
setBackground(Color.DARK_GRAY); |
|
|
contentPane.setForeground(new Color(0, 0, 0)); |
|
|
|
|
|
contentPane.setBackground(new Color(128, 128, 128)); |
|
|
|
|
|
|
|
|
contentPane.setForeground(paneFarbeForeground); |
|
|
|
|
|
contentPane.setBackground(paneFarbeBackground); |
|
|
|
|
|
|
|
|
JLabel labelStart = new JLabel("Start"); |
|
|
JLabel labelStart = new JLabel("Start"); |
|
|
labelStart.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
labelStart.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
labelStart.setFont(new Font("Tahoma", Font.BOLD, 30)); |
|
|
|
|
|
|
|
|
labelStart.setFont(fontTahoma); |
|
|
labelStart.setBounds(10, 11, 83, 49); |
|
|
labelStart.setBounds(10, 11, 83, 49); |
|
|
contentPane.add(labelStart); |
|
|
contentPane.add(labelStart); |
|
|
|
|
|
|
|
|
JLabel labelZiel = new JLabel("Ziel"); |
|
|
JLabel labelZiel = new JLabel("Ziel"); |
|
|
labelZiel.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
labelZiel.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
labelZiel.setFont(new Font("Tahoma", Font.BOLD, 30)); |
|
|
|
|
|
|
|
|
labelZiel.setFont(fontTahoma); |
|
|
labelZiel.setBounds(809, 525, 67, 49); |
|
|
labelZiel.setBounds(809, 525, 67, 49); |
|
|
contentPane.add(labelZiel); |
|
|
contentPane.add(labelZiel); |
|
|
|
|
|
|
|
|
JPanel panel = new JPanel(); |
|
|
JPanel panel = new JPanel(); |
|
|
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2)); |
|
|
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2)); |
|
|
panel.setForeground(new Color(0, 0, 0)); |
|
|
panel.setForeground(new Color(0, 0, 0)); |
|
|
panel.setBounds(103, 11, 696, 569); |
|
|
|
|
|
|
|
|
panel.setBounds(103, 11, breitePanel, hoehePanel); |
|
|
contentPane.add(panel); |
|
|
contentPane.add(panel); |
|
|
panel.setLayout(null); |
|
|
panel.setLayout(null); |
|
|
|
|
|
|
|
|
JPanel nordWand = new JPanel(); |
|
|
JPanel nordWand = new JPanel(); |
|
|
reset(nordWand); |
|
|
reset(nordWand); |
|
|
nordWand.setBackground(new Color(0, 0, 0)); |
|
|
|
|
|
|
|
|
nordWand.setBackground(panelRahmenFarbeBackground); |
|
|
nordWand.setBounds(0, 0, 696, 10); |
|
|
nordWand.setBounds(0, 0, 696, 10); |
|
|
panel.add(nordWand); |
|
|
panel.add(nordWand); |
|
|
|
|
|
|
|
|
JPanel suedWand = new JPanel(); |
|
|
JPanel suedWand = new JPanel(); |
|
|
reset(suedWand); |
|
|
reset(suedWand); |
|
|
suedWand.setBackground(new Color(0, 0, 0)); |
|
|
|
|
|
|
|
|
suedWand.setBackground(panelRahmenFarbeBackground); |
|
|
suedWand.setBounds(0, 559, 696, 10); |
|
|
suedWand.setBounds(0, 559, 696, 10); |
|
|
panel.add(suedWand); |
|
|
panel.add(suedWand); |
|
|
|
|
|
|
|
|
JPanel ostWand = new JPanel(); |
|
|
JPanel ostWand = new JPanel(); |
|
|
reset(ostWand); |
|
|
reset(ostWand); |
|
|
ostWand.setBackground(new Color(0, 0, 0)); |
|
|
|
|
|
|
|
|
ostWand.setBackground(panelRahmenFarbeBackground); |
|
|
ostWand.setBounds(686, 0, 10, 509); |
|
|
ostWand.setBounds(686, 0, 10, 509); |
|
|
panel.add(ostWand); |
|
|
panel.add(ostWand); |
|
|
|
|
|
|
|
|
JPanel westWand = new JPanel(); |
|
|
JPanel westWand = new JPanel(); |
|
|
reset(westWand); |
|
|
reset(westWand); |
|
|
westWand.setBackground(new Color(0, 0, 0)); |
|
|
|
|
|
|
|
|
westWand.setBackground(panelRahmenFarbeBackground); |
|
|
westWand.setBounds(0, 60, 10, 509); |
|
|
westWand.setBounds(0, 60, 10, 509); |
|
|
panel.add(westWand); |
|
|
panel.add(westWand); |
|
|
|
|
|
|
|
@ -125,6 +137,21 @@ public class MouseGame extends JFrame { |
|
|
}//end standardkonstruktor |
|
|
}//end standardkonstruktor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JPanel getContentPane() { |
|
|
|
|
|
return contentPane; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Color getPanelRahmenFarbeBackground() { |
|
|
|
|
|
return panelRahmenFarbeBackground; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Font getFontTahoma() { |
|
|
|
|
|
return fontTahoma; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getResetX() { |
|
|
public int getResetX() { |
|
|
return resetX; |
|
|
return resetX; |
|
|
} |
|
|
} |
|
@ -135,6 +162,26 @@ public class MouseGame extends JFrame { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getBreiteFrame() { |
|
|
|
|
|
return breiteFrame; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getHoeheFrame() { |
|
|
|
|
|
return hoeheFrame; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getBreitePanel() { |
|
|
|
|
|
return breitePanel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getHoehePanel() { |
|
|
|
|
|
return hoehePanel; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void reset(JPanel panel) { |
|
|
private void reset(JPanel panel) { |
|
|
panel.addMouseListener(new MouseAdapter() { |
|
|
panel.addMouseListener(new MouseAdapter() { |
|
|
@Override |
|
|
@Override |
|
|