blob: bc32d4714169bc6e4e7a9cdf59189503c26ca327 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* Created on 17.10.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author sven
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.awt.*;
import javax.swing.*;
public class test extends JFrame{
Container c;
JLabel beschrift;
public test()
{
c = getContentPane();
c.setLayout(new FlowLayout());
beschrift = new JLabel ("Text im Frame");
c.add(beschrift);
}
public test(String[] labelText)
{
/**
* @param labelText in
*/
c = getContentPane();
c.setLayout(new FlowLayout());
String LabelText="";
for (int i=1;i<labelText.length;i++) {
LabelText=LabelText+" "+labelText[i];
}
for (int i=0;i<Integer.parseInt(labelText[0]);i++) {
beschrift = new JLabel (LabelText+" "+(i+1));
beschrift.setForeground(getRandomColor());
beschrift.setBackground(getRandomColor());
beschrift.setOpaque(true);
c.add(beschrift);
}
}
public void hilfe() {
System.out.println("Call: <progamname> [<nr-labels>] [<label-text1>]");
}
public Color getRandomColor() {
Color myColor = new Color ((float) Math.random(),(float) Math.random(),(float) Math.random());
return myColor;
}
public static void main(String[] args) {
test TestWinClass;
if (args.length == 0) {
TestWinClass = new test();
TestWinClass.hilfe();
}
else {
TestWinClass = new test(args);
}
TestWinClass.setTitle("Frame mit Text");
TestWinClass.setSize(300,150);
TestWinClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TestWinClass.setVisible(true);
}
}
|