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]); } } }