fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
Success #stdin #stdout 0.08s 49040KB
stdin
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class frame6 extends Applet implements ActionListener
{
Label l1,l2,l3,l4;
TextField t1,t2,t3,t4;
Button b1,b2;
public void init()
{
Frame f=new Frame("My Details Using Text Fields");
f.setLayout(new GridLayout(8,9));
f.setSize(500,500);
setForeground(Color.black);
l1=new Label("Name");
l2=new Label("Street");
l3=new Label("City");
l4=new Label("Pin");
t1=new TextField(10);
t2=new TextField(10);
t3=new TextField(10);
t4=new TextField(10);
b1=new Button("MY DETAILS");
b2=new Button("CLEAR");
add(l1);
add(l2);
add(l3);
add(l4);
add(t1);
add(t2);
add(t3);
add(t4);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void paint(Graphics g)
{
Font f1=new Font("Arail",Font.ITALIC+Font.BOLD,30);
g.setFont(f1);
g.setColor(Color.red);
g.drawString("Displaying My Details",10,30);
l1.setLocation(50,50);
t1.setLocation(100,50);
l2.setLocation(50,100);
t2.setLocation(100,100);
l3.setLocation(50,150);
t3.setLocation(100,150);
l4.setLocation(50,200);
t4.setLocation(100,200);
b1.setLocation(100,300);
b2.setLocation(200,300);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
t1.setText("Poorani");
t2.setText("kangeyam road");
t3.setText("Tirupur");
t4.setText("641604");
}
if(e.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
}
}
}
//<applet code=frame6.class width=500 height=500>
//</applet>
stdout
Standard output is empty