11/10/12 20:56
bububs
Innanzitutto ciao e grazie per la risposta
ti faccio vedere cosa ho fatto però non mi da nessun testo e nessun colore
package shapedraw;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JLabel;
/**
*
* @author Bububs
*/
public class MyJLabel extends JLabel {
public static JLabel label;
private Color startColor = new Color(192, 192, 192);
private Color endColor = new Color(82, 82, 82);
private String testo = "";
private GradientPaint GP;
public MyJLabel(String text, Color coloreBase) {
super("");
setText("");
testo = text;
startColor = Utility.schiarisciColore(coloreBase);
endColor = Utility.scurisciColore(coloreBase);
setForeground(Color.WHITE);
setHorizontalAlignment(JLabel.CENTER);
setFocusable(false);
setOpaque(true);
label = (JLabel) this;
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
GP = new GradientPaint(0, 0, startColor, 0, getHeight(), endColor, true);
g2d.setPaint(GP);
g2d.drawString(testo, 0, 0);
g2d.dispose();
super.paintComponent(g);
}
}
come mai non esce ciò che mi aspetto?
Ultima modifica effettuata da bububs 11/10/12 20:58
aaa