summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java
new file mode 100644
index 0000000..33438fc
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2903.java
@@ -0,0 +1,53 @@
+/* Listing2903.java */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class Listing2903
+extends Frame
+{
+ public static void main(String[] args)
+ {
+ Listing2903 wnd = new Listing2903();
+ wnd.setSize(300,200);
+ wnd.setLocation(200,100);
+ wnd.setVisible(true);
+ }
+
+ public Listing2903()
+ {
+ super("Mausklicks");
+ addWindowListener(new WindowClosingAdapter(true));
+ addMouseListener(new MyMouseListener());
+ }
+
+ class MyMouseListener
+ extends MouseAdapter
+ {
+ int cnt = 0;
+
+ public void mousePressed(MouseEvent event)
+ {
+ Graphics g = getGraphics();
+ int x = event.getX();
+ int y = event.getY();
+ if (event.getClickCount() == 1) { //Gesicht
+ ++cnt;
+ //Kopf und Augen
+ g.drawOval(x-10,y-10,20,20);
+ g.fillRect(x-6,y-5,4,5);
+ g.fillRect(x+3,y-5,4,5);
+ //Mund
+ if (event.isMetaDown()) { //grimmig
+ g.drawLine(x-5,y+7,x+5,y+7);
+ } else { //lächeln
+ g.drawArc(x-7,y-7,14,14,225,100);
+ }
+ //Zähler
+ g.drawString(""+cnt,x+10,y-10);
+ } else if (event.getClickCount() == 2) { //Brille
+ g.drawLine(x-9,y-3,x+9,y-3);
+ }
+ }
+ }
+} \ No newline at end of file