AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit Mausereignis (JAVA)

Ein Thema von Dannyboy · begonnen am 30. Mär 2004 · letzter Beitrag vom 31. Mär 2004
 
Benutzerbild von d3g
d3g

Registriert seit: 21. Jun 2002
602 Beiträge
 
#5

Re: Problem mit Mausereignis (JAVA)

  Alt 30. Mär 2004, 16:10
Ha! Ich hab's jetzt doch geschafft.

Zwei Fehler hast du gemacht:
1. Du hast setDesign() aufegrufen, bevor du myMouse instanziert hast, so dass alle Buttons mit null als Listener gespeist wurden.
2. Du weist den Feldern ok, cancel, etc. nichts zu. Ja, instance wird in den Funktionen erzeugt, aber das hat keine Auswirkung auf die Variable, die du übergibst. Warum, frag mich jetzt bitte nicht, ich habe es auch schon so gemacht wie du und das Stichwort Call-by-Reference sollte eigentlich auxch bedeuten, dass dein Ansatz funktioniert. Das tut es nur nicht. Keine Ahnung, warum (in meinem Zustand nicht). Wie auch immer, so geht's:

Code:
// KONSTRUKTOREN

   Mainframe(String title) {
      this.f = new Frame();
      f.setLayout(null);
      f.setSize(clientWidth, clientHeight);
      f.setTitle(title);
      f.addWindowListener(new MyWindowAdapter());
      myMouse = new MyMouseAdapter();
      f.addMouseListener(myMouse);
      setDesign();
      f.show();
   }
 
//******************************************************************************************//
 
  // Methode legt das komplette Design des Formulars fest.
 
   private void setDesign() {
      final int middleX = clientWidth / 2;
     
       stdIn_Lab = createLabel(leftAlign, 25, 90, labelheight, "<Eingabe>");
       stdIn = createTextField(leftAlign, 50, 275, textfieldheight, "");
      ok = createButton(leftAlign, 90, 85, buttonheight, "OK");
      snap = createButton(115, 90, 85, buttonheight, "SNAP-MENU");
      cancel = createButton(210, 90, 85, buttonheight, "CANCEL");
   
      stdErr_Lab = createLabel(leftAlign, 130, 100, labelheight, "<Standard Error>");
      stdErr = createTextArea(leftAlign, 160, 290, 295, "<Dies ist Standard Error>");
       rCode_Lab = createLabel(leftAlign, 465, 90, labelheight, "<return code>");
      rCode = createTextField(leftAlign, 495, 275, textfieldheight, "");
   
      stdOut_Lab = createLabel(middleX, 25, 90, labelheight, "<Standard Out>");
      stdOut = createTextArea(middleX, 50, middleX - 20, 430, "<Dies ist Standard Out>");
     
      exit = createButton(middleX, 495, middleX - 20, buttonheight, "Close Window");
   }
 
 
//******************************************************************************************//
 
// Methode erstellt ein Textfeld (einzeilige Komponente)

   private TextField createTextField(int x, int y, int width, int height, String s) {
      TextField instance = new TextField(s);
      f.add(instance);
   //      instance.setBackground(bg);
      instance.setBounds(x, y, width, height);
      instance.show();
      return instance;
   }

//******************************************************************************************//

// Methode erstellt eine Textarea (mehrzeilige Komponente)
 
   private TextArea createTextArea(int x, int y, int width, int height, String s) {
      TextArea instance = new TextArea(s);
      f.add(instance);
   //     instance.setBackground(bg);
      instance.setBounds(x, y, width, height);
      instance.show();
      return instance;
    }

//******************************************************************************************//
 
// Methode erstellt ein Label
 
   private Label createLabel(int x, int y, int width, int height, String s) {
      Label instance = new Label(s);
      f.add(instance);
      instance.setBounds(x, y, width, height);
      instance.show();
      return instance;
    }
 
//******************************************************************************************//
 
// Methode erstellt einen Button
 
    private Button createButton(int x, int y, int width, int height, String s) {
      Button instance = new Button(s);
      f.add(instance);
      instance.setBounds(x, y, width, height);
      instance.addMouseListener(myMouse);
      instance.show();
      return instance;
    }
-- Crucifixion?
-- Yes.
-- Good. Out of the door, line on the left, one cross each.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz