AboutBox

Aus Programmers Guide

Wechseln zu: Navigation, Suche
import java.awt.event.*;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class AboutBox extends Frame
{
private static final long serialVersionUID = 1L;
private Label l1;
private JLabel l2;
private Label l3;
private Label l4;
private Label l5;
private Label l6;
private Button b1;
 
public AboutBox ()
{
setTitle("Über Programm");
addWindowListener(new ExitWindowListener());
 
setLayout(null); // "Null-Layout" setzen
setBackground(backGroundColor);
Image image = Toolkit.getDefaultToolkit().getImage(
AboutBox.class.getResource( logoString ) );
l1 = new Label("Titelanzeige");
l1.setBounds(40, 30, 170, 15); // x, y, breite, höhe
l1.setForeground(schriftFarbe);
ImageIcon image1 = new ImageIcon(AboutBox.class.getResource(logoString));
l2 = new JLabel( image1 );
l2.setBounds(5,30,30,30);
l2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
l3 = new Label("Autor: Roy Bohn");
l3.setBounds(40,45,170,15);
l3.setForeground(schriftFarbe);
l4 = new Label("E-Mail: ");
l4.setBounds(40,60,170,15);
l4.setForeground(schriftFarbe);
l5 = new Label("Version: ");
l5.setBounds(40,75,170,15);
l5.setForeground(schriftFarbe);
l6 = new Label("Datum: ");
l6.setBounds(40,90,170,15);
l6.setForeground(schriftFarbe);
 
b1 = new Button();
b1.setBounds(110,125,80,20);
b1.setLabel("schliessen");
b1.setForeground(schriftFarbe);
b1.setBackground(backGroundColor);
b1.setFont(schrift);
b1.setName("Fenster schliessen");
b1.addActionListener(buttonListener);
 
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(b1);
setIconImage(image);
 
DisplayMode dMode = null;
 
GraphicsConfiguration gc = getGraphicsConfiguration();
GraphicsDevice gd = gc.getDevice();
dMode = gd.getDisplayMode();
 
int width = dMode.getWidth()/2-150;
int height = dMode.getHeight()/2-77;
this.setLocation(width,height);
setSize(300,150);
setResizable(false);
this.setUndecorated(true);
//setLocationByPlatform(true);
setVisible(true);
}
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent event) {
dispose();
}
};
class ExitWindowListener extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
e.getWindow().dispose();
}
}
public static void main (String args[])
{
new AboutBox ();
}
}
Persönliche Werkzeuge