souce code: dateshow.java
import java.awt.*;
import java.util.*;
import java.awt.event.*;
class dateshow extends Frame
{
Font f1=new Font("High Tower Text",Font.BOLD,18);
Label lb;
public dateshow(){
setLayout(null);
lb=new Label("date"); // create label
Button b1=new Button("date");//create button
b1.setBounds(100,80,100, 40);
lb.setBounds(50,120,300, 50);
add(b1);//adding button on frame
add(lb);// adding label to frame
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
Date d=new Date();
lb.setFont(f1);
lb.setText(""+d);
}
});
}
public static void main(String[] args) {
dateshow f=new dateshow();
f.setSize(400,500);
f.setVisible(true);
}
}
output:
0 Comments
Post a Comment