import java.awt.*;
class FirstFrame extends Frame {
FirstFrame() {
Button b = new Button("ok");
b.setBounds(30, 100, 80, 30);
add(b);
setSize(400, 400);
setLayout(null);
setVisible(true);
}
public static void main(String args[]) {
FirstFrame f = new FirstFrame();
}
}
Asked
Active
Viewed 546 times
0

MadProgrammer
- 343,457
- 22
- 230
- 366

user2601676
- 1
- 1
- 4
-
The class is called `FirstFrame` – MadProgrammer Sep 19 '13 at 07:08
-
yes i have called FirstFrame extends Frame class – user2601676 Sep 19 '13 at 07:15
-
Then what is the question...? – MadProgrammer Sep 19 '13 at 07:16
-
but error show "cannot access Frame, file does not cantain class Frame " – user2601676 Sep 19 '13 at 07:23
-
Nope, works fine for me. Is the file name called `FirstFrame.java`? – MadProgrammer Sep 19 '13 at 07:25
-
but i have get error....why – user2601676 Sep 19 '13 at 07:29
-
What IDE are you using? – Vignesh Vino Sep 19 '13 at 07:40
-
What error? When? How? – MadProgrammer Sep 19 '13 at 08:04
-
cannot access Frame,file does not contain class frame – user2601676 Sep 19 '13 at 08:07
-
Whatever resource being used for learning? Burn it. AWT (yuck(1)) `setBounds(..)` (groan) `setSize(..)` (yawn) `setLayout(null)` (retch..). 1) Why AWT rather than Swing? See this answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see [Mixing Heavyweight and Lightweight Components](http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html). – Andrew Thompson Sep 19 '13 at 09:23
2 Answers
0
You may have accidentally created any other .java file named "Frame" in your present directory. If you have any such .java file then rename it to other name

P.Sharan
- 29
- 4
0
It's simply means that you have created a file with name "Frame.java", just change it's name and your run your program. Please remove or make sure it appears in the correct subdirectory of the sourcepath. As your program cannot access the actual Java.awt.Frame class, as you have created some other Frame class, so your program is unable to differentiate because of ambiguous statement. Stay Blessed!