Button fills up whole of the frame !! what am I doing wrong??

I am trying to open a frame from an applet and I have put a button in the frame .
But , it fills up the frame window..
How can I make it into normal sized button..???
code is given below..
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class SampleFrame extends Frame {
String msg=" ";
Button b2;
SampleFrame(String title) {
super(title);
b2 = new Button("Iterate");
add(b2);
b2.addActionListener(this);
MyWindowAdapter adapter=new MyWindowAdapter(this);
addWindowListener(adapter);
public void paint(Graphics g)
g.drawString("This is in 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);
public class appframe extends Applet implements ActionListener {
Frame f;
Button b1;
public void init() {
b1 = new Button("Enter");
add(b1);
b1.addActionListener(this);
f = new SampleFrame("A Frame Window");
f.setSize(250, 250);
setBackground(Color.cyan);
public void stop()
f.setVisible(false);
public void actionPerformed(ActionEvent ae){
String str = ae.getActionCommand();
if(str.equals("Enter"))
f.setVisible(true);
public void paint(Graphics g)
g.drawString("This is in applet window", 10, 20);
}

I got the reply to this post...

Similar Messages

Maybe you are looking for