import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import javax.swing.*;
import javax.swing.JFrame;
public class Gui_v4 {
public static void main(String[] args) {
JFrame f = new JFrame("ID");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(560, 200);
f.setVisible(true);
f.setLayout(null ); //new GridLayout(3, 3));
////////////////////////////////////////////
//ActionListener
////////////////////////////////////////////
ActionListener a1 = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
ActionListener a2 = new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
};
////////////////////////////////////////////
//LABEL
////////////////////////////////////////////
JLabel l1 = new JLabel("Host");
l1.setForeground(Color.BLUE);
l1.setBounds(10, 20, 90, 20);
f.add(l1);
JLabel l2 = new JLabel("SID");
l2.setForeground(Color.BLUE);
l2.setBounds(110, 20, 90, 20);
f.add(l2);
JLabel l3 = new JLabel("Mandant");
l3.setForeground(Color.BLUE);
l3.setBounds(220, 20, 90, 20);
f.add(l3);
JLabel l4 = new JLabel("Anwender-NR.");
l4.setForeground(Color.BLUE);
l4.setBounds(330, 20, 90, 20);
f.add(l4);
JLabel l5 = new JLabel("Jahr");
l5.setForeground(Color.BLUE);
l5.setBounds(440, 20, 90, 20);
f.add(l5);
JLabel la1 = new JLabel("");
la1.setForeground(Color.BLUE);
la1.setBounds(10, 70, 90, 20);
f.add(la1);
JLabel la2 = new JLabel("");
la2.setForeground(Color.BLUE);
la2.setBounds(110, 70, 90, 20);
f.add(la2);
JLabel la3 = new JLabel("");
la3.setForeground(Color.BLUE);
la3.setBounds(220, 70, 90, 20);
f.add(la3);
JLabel la4 = new JLabel("");
la4.setForeground(Color.BLUE);
la4.setBounds(330, 70, 90, 20);
f.add(la4);
JLabel la5 = new JLabel("");
la5.setForeground(Color.BLUE);
la5.setBounds(440, 70, 90, 20);
f.add(la5);
////////////////////////////////////////////
//Button
////////////////////////////////////////////
final JButton EXIT = new JButton("Exit");
f.getContentPane().add(EXIT /*BorderLayout.SOUTH*/);
EXIT.setPreferredSize(new java.awt.Dimension(65, 35));
f.add(EXIT);
EXIT.setBounds(275, 105 /*75*/, 155, 20);
EXIT.addActionListener(a1);
final JButton RESET = new JButton("Reset");
f.getContentPane().add(RESET /*BorderLayout.SOUTH*/);
RESET.setPreferredSize(new java.awt.Dimension(65, 35));
f.add(RESET);
RESET.setBounds(110, 105/*75*/, 155, 20);
RESET.addActionListener(a2);
////////////////////////////////////////////
//Date
////////////////////////////////////////////
Date dt = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy");
df.setTimeZone(TimeZone.getDefault());
String n = df.format(dt);
double zahl=Double.valueOf( n ).doubleValue();
zahl = zahl - 2;
String pos1 = (int)zahl+"";
zahl = zahl +1;
String pos2 = (int)zahl+"";
zahl = zahl +1;
String pos3 = (int)zahl+"";
zahl = zahl +1;
String pos4 = (int)zahl+"";
zahl = zahl +1;
String pos5 = (int)zahl+"";
////////////////////////////////////////////
//ComboBox
////////////////////////////////////////////
String[] dateStrings = { pos1 , pos2 , pos3 , pos4 , pos5 };
JComboBox Host = new JComboBox(dateStrings);
Host.setSelectedIndex(4);
Host.setBounds(10, 45, 90, 20);
Host.setForeground(Color.BLACK);
f.add(Host);
//Host.addActionListener(a2);
JComboBox SID = new JComboBox(dateStrings);
SID.setSelectedIndex(4);
SID.setBounds(110, 45, 100, 20);
SID.setForeground(Color.BLACK);
f.add(SID);
//SID.addActionListener(a2);
JComboBox Mand = new JComboBox(dateStrings);
Mand.setSelectedIndex(4);
Mand.setBounds(220, 45, 100, 20);
Mand.setForeground(Color.BLACK);
f.add(Mand);
//Mand.addActionListener(a2);
JComboBox anw = new JComboBox(dateStrings);
anw.setSelectedIndex(4);
anw.setBounds(330, 45, 100, 20);
anw.setForeground(Color.BLACK);
f.add(anw);
//anw.addActionListener(a2);
JComboBox Jahr = new JComboBox(dateStrings);
Jahr.setSelectedIndex(4);
Jahr.setBounds(440, 45, 100, 20);
Jahr.setForeground(Color.BLACK);
f.add(Jahr);
//Jahr.addActionListener(a2);
}
}