package beispiele;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Fenster extends JFrame{
JButton b1,b2,b3,b4,b5;
JTextField t1;
JProgressBar pb1;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12;
String ergstring = "";
int[] wert = new int[2];
int lauf=0;
PPanel3 p3;
public Fenster(){
super("Drehwinkel - Erfassung");
p3=new PPanel3();
JMenuBar menuBar=new JMenuBar();
JMenu fileMenu=new JMenu("Datei");
menuBar.add(fileMenu);
this.setJMenuBar(menuBar);
fileMenu.add(new JMenuItem("Neu"));
fileMenu.add(new JMenuItem("Laden"));
fileMenu.addSeparator();
fileMenu.add(new JMenuItem("Speichern"));
fileMenu.add(new JMenuItem("Drucken"));
fileMenu.addSeparator();
Action exitAction=new AbstractAction("Beenden"){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
};
fileMenu.add(exitAction);
JMenu fileMenu2=new JMenu("Bearbeiten");
menuBar.add(fileMenu2);
this.setJMenuBar(menuBar);
fileMenu2.add(new JMenuItem("Kopieren"));
fileMenu2.add(new JMenuItem("Einfügen"));
fileMenu2.add(new JMenuItem("Ausschneiden"));
fileMenu2.addSeparator();
fileMenu2.add(new JMenuItem("Tastenkürzel"));
JMenu helpMenu=new JMenu("?");
menuBar.add(helpMenu);
helpMenu.add(new JMenuItem("Hilfe"));
helpMenu.addSeparator();
helpMenu.add(new JMenuItem("Über das Programm"));
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
Container contentPane=this.getContentPane();
contentPane.setLayout(null);
b1=new JButton("Auslesen");
b2=new JButton("Speichern");
b3=new JButton("Übergeben");
b4=new JButton("Wechsel");
b5=new JButton("Unten");
t1=new JTextField("");
l1=new JLabel("");
l2=new JLabel("");
l3=new JLabel("");
l4=new JLabel("");
l5=new JLabel("");
l6=new JLabel("");
l7=new JLabel("");
l8=new JLabel("");
l9=new JLabel("");
l10=new JLabel("");
l11=new JLabel("Werte:");
pb1=new JProgressBar();
contentPane.add(p3).setBounds(120,20,294,286);
contentPane.add(b1).setBounds(520,10,120,30);
contentPane.add(b2).setBounds(520,50,120,30);
contentPane.add(b3).setBounds(520,90,120,30);
contentPane.add(b4).setBounds(520,130,120,30);
contentPane.add(t1).setBounds(183,365,120,20);
contentPane.add(l11).setBounds(520,170,120,20);
contentPane.add(l1).setBounds(520,190,120,20);
contentPane.add(l2).setBounds(520,210,120,20);
contentPane.add(l3).setBounds(520,230,120,20);
contentPane.add(l4).setBounds(520,250,120,20);
contentPane.add(l5).setBounds(520,270,120,20);
contentPane.add(l6).setBounds(520,290,120,20);
contentPane.add(l7).setBounds(520,310,120,20);
contentPane.add(l8).setBounds(520,330,120,20);
contentPane.add(l9).setBounds(520,350,120,20);
contentPane.add(l10).setBounds(520,370,120,20);
contentPane.add(pb1).setBounds(135,390,222,25);
this.setBounds(100,100,655,600);
this.setResizable(false);
this.setVisible(true);
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String s1=t1.getText();
// umwandeln in interger-format und speichern als z1!!
int z1 = Integer.parseInt(s1);
wert[lauf] = z1;
lauf ++;
}
}
);
b3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
ausgeben();
}
}
);
}
int x=0;
public void ausgeben(){
ergstring = ergstring+String.valueOf(wert[x]);
x++;
l1.setText(ergstring);
}
}
class PPanel3 extends JPanel {
JLabel l12;
Image img;
public PPanel3() {
img=Toolkit.getDefaultToolkit().createImage("IMAG0030.gif");
}
public void paintComponent(Graphics g){
g.drawImage(img,0,0 ,this);
}
}
class sendToParPort
{
static final short Addr = 0x378;
static short data;
static pPort lpt;
public sendToParPort(int value) // zB value = 10;
{
lpt = new pPort();
data = (short)value;
do_write();
}
static void do_read()
{
data = (short) lpt.input(Addr);
}
static void do_write()
{
lpt.output(Addr,data);
}
}
public class MFenster {
public static void main(String[] args){
new Fenster();
}
}