summaryrefslogtreecommitdiffstats
path: root/Bachelor/ERGO/Praktikum1
diff options
context:
space:
mode:
Diffstat (limited to 'Bachelor/ERGO/Praktikum1')
-rw-r--r--Bachelor/ERGO/Praktikum1/test.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/Bachelor/ERGO/Praktikum1/test.java b/Bachelor/ERGO/Praktikum1/test.java
new file mode 100644
index 0000000..bc32d47
--- /dev/null
+++ b/Bachelor/ERGO/Praktikum1/test.java
@@ -0,0 +1,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);
+
+ }
+}