public PanelColor(int id, Fenetre f, DisplayColor dc, Button backButton, int w, int h) { this.estConstructeurBis = true; this.bgColor = dc.getBackground(); this.dc = dc; this.setBounds(0, 0, w, h); this.lastButton = backButton; this.setBackground(this.bgColor); this.add(colorB); this.add(colorG); this.add(colorR); System.out.println(this.lastButton); this.colorB.setColor("" + this.lastButton.getColor().getBlue()); this.colorR.setColor("" + this.lastButton.getColor().getRed()); this.colorG.setColor("" + this.lastButton.getColor().getGreen()); this.colorChoice.setBackground(lastButton.getColor()); this.next.setId(lastButton.getId()); choseColor.addMouseListener(this); this.add(choseColor); // this.add(this.numColor); this.frame = f; this.setSize(new Dimension(w, h)); this.setLayout(null); this.addMouseListener(this); // carreColor.setMaximumSize(new Dimension(200, 200)); this.add(carreColor); validColor(colorR.getColor(), colorG.getColor(), colorB.getColor()); this.add(colorChoice); this.next.addMouseListener(this); this.add(next); neededGrey = maxGrey / (frame.getNmbColor()); frame.setNeededGrey(neededGrey); }
@Override public void mouseClicked(MouseEvent arg0) { Button b; if (arg0.getSource() instanceof Button) { b = (Button) arg0.getSource(); int red = this.stringToInt(this.colorR.getText()); int green = this.stringToInt(this.colorG.getText()); int blue = this.stringToInt(this.colorB.getText()); if (arg0.getSource() == next) { if (this.nmbColor != 0) { this.frame.getDC().addColor(new Color(red, green, blue)); b.setColor(this.colorChoice.getBackground()); this.frame.setContentPane( new PanelColor( this.frame, "menuColorChoice", this.nmbColor, this.bgColor, this.getWidth(), this.getHeight())); } else { if (estConstructeurBis == true) { System.out.println("id ===== " + b.getId()); dc.getButtonList().get(b.getId()).setBackground(new Color(red, green, blue)); dc.getButtonList().get(b.getId()).setColor(new Color(red, green, blue)); // dc.getButtonList().set(b.getId(), b); dc.repaint(); // this.frame.getDC().updatePanel(); this.frame.setContentPane(dc); dc.repaint(); this.frame.revalidate(); estConstructeurBis = false; } else { this.frame .getDC() .addColor( new Color( this.stringToInt(this.colorR.getText()), this.stringToInt(this.colorG.getText()), this.stringToInt(this.colorB.getText()))); b.setColor(this.colorChoice.getBackground()); this.frame.getDC().updatePanel(); this.frame.setContentPane(this.frame.getDC()); } } frame.setGreyIndicator(neededGrey); this.frame.revalidate(); } else if (arg0.getSource() == choseColor) { PrecisePanel p = new PrecisePanel( this.frame, this, this.getBackground(), 0, 0, this.getWidth(), this.getHeight()); this.frame.setContentPane(p); this.frame.revalidate(); } else { System.out.println(colorR.getText() + " " + colorG.getText() + " " + colorB.getText()); this.colorR.setColor(colorR.getText()); this.colorG.setColor(colorG.getText()); this.colorB.setColor(colorB.getText()); validColor(colorR.getColor(), colorG.getColor(), colorB.getColor()); this.colorR.setText("" + colorR.getColor()); this.colorG.setText("" + colorG.getColor()); this.colorB.setText("" + colorB.getColor()); this.repaint(); } } }