Calling a method on top object?

Say I have my top level class, App extends JFrame, and I want to call the getlocation method on it within on of its functions. I cant do super().getLocation. So what do I do?
[181 byte] By [jdk2006a] at [2007-11-27 5:36:53]
# 1
Not sure I follow.If your class extends Jframe then you simply use getLocation().
_helloWorld_a at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 2

Are you overriding super's getLocation method? If not you just call it.

abstract class ABaseClass {

public aMethod() { System.out.println("ABaseClass.aMethod"); }

public bMethod() { System.out.println("ABaseClass.bMethod"); }

}

class ARealClass extends ABaseClass {

public aMethod() { System.out.println("ARealClass.bMethod"); }

public static void main(String[] args) {

ARealClass c = new ARealClass();

c.aMethod();

c.bMethod();

}

}

Try and guess what gets printed before you run it.

Keith.

corlettka at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 3
you could also call it from the this keyword.this.getLocation();
RedUnderTheBeda at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 4
i actually want ot call it from an action listener that is within the app constructor
jdk2006a at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 5
first call super(); to contruct the super class.
corlettka at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 6

here is some pseudo code

public class App extends JFrame {

public App() {

ActionListener...{

getLocation() //this should be called to find the window location, it is a JFrame method

}

}

jdk2006a at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 7
Yeah, doesn't that work?
corlettka at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 8
If you are inside an local class (or inner class?) tryApp.this.getLocation()
S_i_m_ua at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 9

Here's the code.

public class App extends javax.swing.JFrame {

Rectangle _captureArea;

public App() {

initComponents();

captureButton.addActionListener(new ActionListener( ) {

public void actionPerformed(ActionEvent ev) {

_captureArea = new Rectangle(App.this.getLocationOnScreen().getX()-320, App.this.getLocationOnScreen().getY(), 320, 45);

}

});

} //end of constructor

//...

}

Here is the error:

init:

deps-jar:

Compiling 1 source file to C:\Documents and Settings\James Kovacs\TextTwistPlayer\build\classes

C:\Documents and Settings\James Kovacs\TextTwistPlayer\src\App.java:39: cannot find symbol

symbol : constructor Rectangle(double,double,int,int)

location: class java.awt.Rectangle

_captureArea = new Rectangle(App.this.getLocationOnScreen().getX()-320, App.this.getLocationOnScreen().getY(), 320, 45);

1 error

BUILD FAILED (total time: 1 second)

Message was edited by:

jdk2006

jdk2006a at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...
# 10

Rectangle has no constructor with (double, double, int, int) arguments, only (int, int, int, int).

getX() anf getY() are returning double, use .x and .y to get int

(or cast the result from getX() and getY() to int).

_captureArea = new Rectangle(App.this.getLocationOnScreen().x-320, App.this.getLocationOnScreen().y, 320, 45);

S_i_m_ua at 2007-7-12 15:08:23 > top of Java-index,Java Essentials,Java Programming...