summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing3701.java
blob: 58c57d9b9a9e38ab28abd661747b7ac94eed4fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Listing3701.java */

import java.awt.*;
import javax.swing.*;

public class Listing3701
extends JFrame
{
  public Listing3701()
  {
    super("JLabel");
    addWindowListener(new WindowClosingAdapter(true));
    Container cp = getContentPane();
    cp.setLayout(new GridLayout(5, 1));
    JLabel label;
    //Standardlabel
    label = new JLabel("Standard-Label");
    cp.add(label);
    //Label mit Icon
    label = new JLabel(
      "Label mit Icon",
      new ImageIcon("lock.gif"),
      JLabel.CENTER
    );
    cp.add(label);
    //Nur-Icon
    label = new JLabel(new ImageIcon("lock.gif"));
    cp.add(label);
    //Icon auf der rechten Seite
    label = new JLabel(
      "Label mit Icon rechts",
      new ImageIcon("lock.gif"),
      JLabel.CENTER
    );
    label.setHorizontalTextPosition(JLabel.LEFT);
    cp.add(label);
    //Label rechts unten
    label = new JLabel("Label rechts unten");
    label.setHorizontalAlignment(JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    cp.add(label);
  }

  public static void main(String[] args)
  {
    Listing3701 frame = new Listing3701();
    frame.setLocation(100, 100);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}