import javax.swing.* ;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.util.Calendar;
import java.util.*;
import java.text.*;
import java.util.Date;
/*
<applet code="gui.class" width=250 height=100>
</applet>
*/
public class gui1 extends JApplet implements ActionListener
{
JTextField t1,t2,t3,t4,t5;
JLabel l1,l2,l3,l4,l5,l6;
JButton b1,b2;
Calendar c1,c2,c3;
JPanel p,p1,p2;
Date sd,sd1;
SimpleDateFormat sdf;
public void init()
{
SimpleDateFormat sdf = new SimpleDateFormat("DD/MM/YYYY");
final JTextField t1 = new JTextField(10);
final JTextField t2 = new JTextField(10);
final JTextField t3 = new JTextField(10);
final JTextField t4 = new JTextField(10);
final JTextField t5 = new JTextField(10);
JLabel l6 = new JLabel("fine");
JLabel l1 = new JLabel("Book Name");
JLabel l2 = new JLabel("Author Namae");
JLabel l3 = new JLabel("Issue Date");
JLabel l4 = new JLabel("Last Date");
JLabel l5 = new JLabel("Submitted Date");
JButton b1=new JButton("Issue");
JButton b2=new JButton("Clear");
setLayout(new BorderLayout());
JPanel p=new JPanel();
p.setLayout(new BoxLayout(p,BoxLayout.Y_AXIS));
p.add(l1);
p.add(l2);
p.add(l3);
p.add(l4);
p.add(l5);
JPanel p1=new JPanel();
p1.setLayout(new BoxLayout(p1,BoxLayout.Y_AXIS));
p1.add(t1);
p1.add(t3);
p1.add(t2);
p1.add(t4);
p1.add(t5);
add(p,BorderLayout.WEST);
add(p1,BorderLayout.EAST);
JPanel p2=new JPanel();
p2.add(b1);
p2.add(b2);
p2.add(l6);
add(p2,BorderLayout.SOUTH);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String s,s1,s2,s3;
s=e.getActionCommand();
if(s.equals("Issue"))
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
}
if(s.equals("Clear"))
{
s2=t4.getText();
s3=t5.getText();
try{
sd=sdf.parse(s2);
sd1=sdf.parse(s3);
long day1=(sd1.getTime() - sd.getTime());
long day=day1/(24*60*60*1000);
if(day <= 0)
{
l6.setText("no fine");
}
else
{
l6.setText("fine of Rs" +day);
}
} //try close
catch (ParseException se)
{
System.out.println("Exception :"+se);
}
} //else close
}
}
This is my new code i have just added the card layout tats all sir **taywin**
Taywin 312 Posting Virtuoso
anandschiru -1 Light Poster
Taywin 312 Posting Virtuoso
anandschiru -1 Light Poster
Taywin 312 Posting Virtuoso
anandschiru -1 Light Poster
anandschiru -1 Light Poster
Taywin 312 Posting Virtuoso
jalpesh_007 commented: nice example +2
anandschiru -1 Light Poster
anandschiru -1 Light Poster
stultuske 1,116 Posting Maven Featured Poster
Taywin 312 Posting Virtuoso
anandschiru -1 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
anandschiru -1 Light Poster
anandschiru -1 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
anandschiru -1 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
anandschiru -1 Light Poster
anandschiru -1 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
anandschiru -1 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Taywin 312 Posting Virtuoso
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Taywin 312 Posting Virtuoso
anandschiru -1 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.