Results 1 to 5 of 5
Thread: working with AWt
- 01-02-2012, 09:29 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
working with AWt
hello,
actually this is just a simple program as to create a child frame window from within an applet
but i really dnt understand why the error is cuming as invalid method declaration - return type required
public MywindowAdapter(SampleFrame sampleFrame)
//Create a child Frame window from within a applet.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
//Create a subclass of frame.
class SampleFrame extends Frame
{
SampleFrame (String title)
{
super (title);
//create an object to handle the window events
MyWindowAdapter adapter = new MyWindowAdapter(this);
//register it to recieve the events
addWindowListener(adapter);
}
public void paint(Graphics g)
{
g.drawString(" this is in the frame window:",10,40);
}
}
class MyWindowAdapter extends WindowAdapter
{
SampleFrame sampleFrame;
public MywindowAdapter(SampleFrame sampleFrame)
{
this.sampleFrame = sampleFrame;
}
public void windowClosing (WindowEvent we)
{
sampleFrame.setVisible(false);
}
}
//create a frame window
public class AppletFrame extends Applet
{
Frame F;
public void init()
{
f = new SampleFrame(" A frame window");
f.setSize(250,250);
f.setvisible(true);
}
public void start()
{
f.setVisible(true);
}
public void stop()
{
f.setVisible(false);
}
public void paint(Graphics g)
{
g.drawString(" this is in the applet window:",10,20);
}
}
kindly help me guys
- 01-02-2012, 09:31 AM #2
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
Re: working with AWt
kindly reply for me
- 01-02-2012, 02:13 PM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Re: working with AWt
Problem with lowercase/uppercase
Java Code://Create a child Frame window from within a applet. import java.awt.*; import java.awt.event.*; import java.applet.*; //Create a subclass of frame. class SampleFrame extends Frame { SampleFrame (String title) { super (title); //create an object to handle the window events MyWindowAdapter adapter = new MyWindowAdapter(this); //register it to recieve the events addWindowListener(adapter); } public void paint(Graphics g) { g.drawString(" this is in the frame window:",10,40); } } class MyWindowAdapter extends WindowAdapter { SampleFrame sampleFrame; public MyWindowAdapter(SampleFrame sampleFrame) { this.sampleFrame = sampleFrame; } public void windowClosing (WindowEvent we) { sampleFrame.setVisible(false); } } //create a frame window public class AppletFrame extends Applet { Frame f; public void init() { f = new SampleFrame(" A frame window"); f.setSize(250,250); f.setVisible(true); } public void start() { f.setVisible(true); } public void stop() { f.setVisible(false); } public void paint(Graphics g) { g.drawString(" this is in the applet window:",10,20); } }Swastik
- 01-03-2012, 01:40 PM #4
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
Re: working with AWt
Thank you but yes there is a new problem as now the error is as -class AppletFrame is public ,should be declared in a file name d AppletFrame.java.
- 01-03-2012, 01:44 PM #5
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Similar Threads
-
Collisions are working & not working
By Jayayoh in forum Java 2DReplies: 1Last Post: 06-24-2011, 05:21 PM -
if else not working
By silverglade in forum New To JavaReplies: 5Last Post: 05-12-2011, 07:29 PM -
\n not working in GUI (working code, but \n isn't working)
By cc11rocks in forum New To JavaReplies: 2Last Post: 01-04-2011, 04:30 AM -
This Is Not Working.
By FatalSylence in forum New To JavaReplies: 8Last Post: 10-16-2010, 02:15 AM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks