0
votes

I used the old API and I have found a few ways to solve the following code (see below, Output code). Now, I have a question, are there other options to use in Frame deprecated Event API without Listener, and why Event doesnt and work with Listeners?

import java.awt.event.*;
import java.awt.*;

public class ClickCoordinates extends Frame{
    Label label;
    
    public ClickCoordinates(){
        label=new Label("Nothing there");
        add(label);
        setLayout(new FlowLayout());
        setVisible(true);
        setSize(300, 300);
    }
    
    public boolean mouseUP(Event evt, int x, int y){
        label.setText("Mouseclick on postition x=" + x + " und y=" + y);
        return true;
    }

    public static void main(String args[]){ new ClickCoordinates(); }
}
In future, please read the fine manual first. Component.mouseUp(Event,int,int) .. "Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).". Speaking of 'old things' generally.. Why use AWT? See this answer for many good reasons to abandon AWT components in favor of Swing.Andrew Thompson