AboutBox
Aus Programmers Guide
Roy (Diskussion | Beiträge) |
Roy (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
- | |||
import java.awt.*;<br>import java.awt.event.*;<br>import javax.swing.BorderFactory;<br>import javax.swing.ImageIcon;<br>import javax.swing.JLabel; <br> public class AboutBox extends Frame<br> {<br> private static final long serialVersionUID = 1L;<br> private Label l1; <br> private JLabel l2;<br> private Label l3;<br> private Label l4;<br> private Label l5;<br> private Label l6;<br> private Button b1;<br> <br> public AboutBox ()<br> {<br> setTitle("Über Programm"); <br> addWindowListener(new ExitWindowListener());<br> <br> setLayout(null); // "Null-Layout" setzen<br> setBackground(backGroundColor);<br> Image image = Toolkit.getDefaultToolkit().getImage( <br> AboutBox.class.getResource( logoString ) ); <br> l1 = new Label("Titelanzeige");<br> l1.setBounds(40, 30, 170, 15); // x, y, breite, höhe<br> l1.setForeground(schriftFarbe);<br> ImageIcon image1 = new ImageIcon(AboutBox.class.getResource(logoString));<br> l2 = new JLabel( image1 );<br> l2.setBounds(5,30,30,30);<br> l2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));<br> l3 = new Label("Autor: Roy Bohn");<br> l3.setBounds(40,45,170,15);<br> l3.setForeground(schriftFarbe);<br> l4 = new Label("E-Mail: ");<br> l4.setBounds(40,60,170,15);<br> l4.setForeground(schriftFarbe);<br> l5 = new Label("Version: ");<br> l5.setBounds(40,75,170,15);<br> l5.setForeground(schriftFarbe);<br> l6 = new Label("Datum: ");<br> l6.setBounds(40,90,170,15);<br> l6.setForeground(schriftFarbe);<br> <br> b1 = new Button();<br> b1.setBounds(110,125,80,20);<br> b1.setLabel("schliessen");<br> b1.setForeground(schriftFarbe);<br> b1.setBackground(backGroundColor);<br> b1.setFont(schrift);<br> b1.setName("Fenster schliessen");<br> b1.addActionListener(buttonListener);<br> <br> add(l1); <br> add(l2);<br> add(l3);<br> add(l4);<br> add(l5);<br> add(l6);<br> add(b1);<br> setIconImage(image);<br> <br> DisplayMode dMode = null;<br> <br> GraphicsConfiguration gc = getGraphicsConfiguration();<br> GraphicsDevice gd = gc.getDevice();<br> dMode = gd.getDisplayMode(); | import java.awt.*;<br>import java.awt.event.*;<br>import javax.swing.BorderFactory;<br>import javax.swing.ImageIcon;<br>import javax.swing.JLabel; <br> public class AboutBox extends Frame<br> {<br> private static final long serialVersionUID = 1L;<br> private Label l1; <br> private JLabel l2;<br> private Label l3;<br> private Label l4;<br> private Label l5;<br> private Label l6;<br> private Button b1;<br> <br> public AboutBox ()<br> {<br> setTitle("Über Programm"); <br> addWindowListener(new ExitWindowListener());<br> <br> setLayout(null); // "Null-Layout" setzen<br> setBackground(backGroundColor);<br> Image image = Toolkit.getDefaultToolkit().getImage( <br> AboutBox.class.getResource( logoString ) ); <br> l1 = new Label("Titelanzeige");<br> l1.setBounds(40, 30, 170, 15); // x, y, breite, höhe<br> l1.setForeground(schriftFarbe);<br> ImageIcon image1 = new ImageIcon(AboutBox.class.getResource(logoString));<br> l2 = new JLabel( image1 );<br> l2.setBounds(5,30,30,30);<br> l2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));<br> l3 = new Label("Autor: Roy Bohn");<br> l3.setBounds(40,45,170,15);<br> l3.setForeground(schriftFarbe);<br> l4 = new Label("E-Mail: ");<br> l4.setBounds(40,60,170,15);<br> l4.setForeground(schriftFarbe);<br> l5 = new Label("Version: ");<br> l5.setBounds(40,75,170,15);<br> l5.setForeground(schriftFarbe);<br> l6 = new Label("Datum: ");<br> l6.setBounds(40,90,170,15);<br> l6.setForeground(schriftFarbe);<br> <br> b1 = new Button();<br> b1.setBounds(110,125,80,20);<br> b1.setLabel("schliessen");<br> b1.setForeground(schriftFarbe);<br> b1.setBackground(backGroundColor);<br> b1.setFont(schrift);<br> b1.setName("Fenster schliessen");<br> b1.addActionListener(buttonListener);<br> <br> add(l1); <br> add(l2);<br> add(l3);<br> add(l4);<br> add(l5);<br> add(l6);<br> add(b1);<br> setIconImage(image);<br> <br> DisplayMode dMode = null;<br> <br> GraphicsConfiguration gc = getGraphicsConfiguration();<br> GraphicsDevice gd = gc.getDevice();<br> dMode = gd.getDisplayMode(); | ||
Version vom 06:46, 30. Mär. 2010
import java.awt.*;
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 ();
}
}