From 84e220b332bfffb0f2dcc39b9697a6fd6691d265 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:36:30 +0200 Subject: Initial commit --- src/aufgaben/b20160413/Zusatz1.java | 84 +++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 src/aufgaben/b20160413/Zusatz1.java (limited to 'src/aufgaben/b20160413/Zusatz1.java') diff --git a/src/aufgaben/b20160413/Zusatz1.java b/src/aufgaben/b20160413/Zusatz1.java new file mode 100755 index 0000000..470a908 --- /dev/null +++ b/src/aufgaben/b20160413/Zusatz1.java @@ -0,0 +1,84 @@ +package aufgaben.b20160413; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Zusatz1 extends Aufgabe { + + private final int width = 110, height = 200; + private boolean done = false; + private String name; + private JSpinner[] spinners; + + public Zusatz1() { + name = "RGB Int Umwandlung"; + this.setSize(width, height); + this.setTitle(name); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + this.setLayout(null); + } + + @Override + public boolean done() { + return done; + } + + @Override + public String getName() { + return name; + } + + @Override + public void init() { + spinners = new JSpinner[4]; + spinners[0] = new JSpinner(new SpinnerNumberModel(0, 0, 16777215, 1)); + spinners[0].setBounds(10, 50, 100, 20); + spinners[1] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[1].setBounds(10, 80, 100, 20); + spinners[2] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[2].setBounds(10, 110, 100, 20); + spinners[3] = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); + spinners[3].setBounds(10, 140, 100, 20); + for(int i = 0; i> 8) & 0xFF)); + spinners[3].setValue((int)(((int)spinners[0].getValue() >> 16) & 0xFF)); + } else if(e.getSource().equals(spinners[1])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } else if(e.getSource().equals(spinners[2])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } else if(e.getSource().equals(spinners[3])) { + spinners[0].setValue((int)spinners[1].getValue() & 0xFF | ((int)spinners[2].getValue() & 0xFF) << 8 | ((int)spinners[3].getValue() & 0xFF) << 16); + } + } + }); + this.add(spinners[i]); + } + } + +} -- cgit v1.2.1