Subtrees hinzugefügt
This commit is contained in:
parent
433a6f2eb1
commit
a02bf698e6
19 changed files with 2775 additions and 0 deletions
90
Quellcodes/sonst_spiel_grosserpreis/ImageLabel.java
Normal file
90
Quellcodes/sonst_spiel_grosserpreis/ImageLabel.java
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* GUI Element zur Anzeige eines Textes vor einem Hintergrundbild
|
||||
*
|
||||
* @version 1.0 from 15.11.2016
|
||||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
|
||||
public class ImageLabel extends JPanel{
|
||||
|
||||
protected ImageIcon image;
|
||||
protected Dimension sizeImage;
|
||||
protected String text;
|
||||
|
||||
public ImageLabel(ImageIcon image) {
|
||||
super();
|
||||
this.image = image;
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ImageLabel(ImageIcon image, String text) {
|
||||
super();
|
||||
this.image = image;
|
||||
this.text = text;
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void init() {
|
||||
sizeImage=new Dimension(image.getIconHeight(),image.getIconWidth());
|
||||
|
||||
}
|
||||
|
||||
public ImageIcon getImageIcon() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImageIcon(ImageIcon image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D graphics2D = (Graphics2D) g;
|
||||
// graphics2D.fillRect(0,0,this.getWidth(),this.getHeight());
|
||||
Composite old=graphics2D.getComposite();
|
||||
if(image!=null)
|
||||
{
|
||||
//graphics2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
|
||||
graphics2D.drawImage(image.getImage(),0,0,
|
||||
this.getWidth(),this.getHeight(),null);
|
||||
}
|
||||
graphics2D.setComposite(old);
|
||||
graphics2D.drawString(text, 8, 40);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Dimension getSizeImage() {
|
||||
return sizeImage;
|
||||
}
|
||||
|
||||
public void setSizeImage(Dimension sizeImage) {
|
||||
this.sizeImage = sizeImage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue