Home > Back-end >  Java do rent calculator, code
Java do rent calculator, code

Time:09-17

/* *
* rental calculator
*/

Package com. My. GUI;

Import the Java. The awt. Container;
Import the Java. The awt. HeadlessException;
Import the Java. The awt. Event. An ActionEvent;
Import the Java. The awt. Event. ActionListener;
Import the Java. The awt. Event. KeyEvent;
Import the Java. The awt. Event. KeyListener;
Import the Java. The awt. Event. MouseEvent;
Import the Java. The awt. Event. MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
Import the Java. Text. A ParseException;

The import javax.mail. Swing. BorderFactory;
The import javax.mail. Swing. The Box;
The import javax.mail. Swing. JButton;
The import javax.mail. Swing. JFrame;
The import javax.mail. Swing. JLabel;
The import javax.mail. Swing. JOptionPane;
The import javax.mail. Swing. JPanel;
The import javax.mail. Swing. JTextField;
The import com.my.util.Com pareTime;
The import com. My. Util. StringUtil;

Public class RentCalculatorFrame extends JFrame implements ActionListener,
KeyListener, MouseListener {

Private JLabel rentPriceMonth;//rent
Private JTextField rentPriceMonthValue;

Private JLabel startDate;
Private JTextField startDateValue;

Private JLabel endDate;
Private JTextField endDateValue;

Private JLabel rentPersonNums;
Private JTextField rentPersonNumsValue;

Private JLabel propertyCost;//other cost
Private JTextField propertyCostValue;

Private JLabel othercost;//other cost
Private JTextField otherCostValue;

Private JLabel sumCost;//total cost
Private JLabel sumCostValue;

Private JLabel everyCost;//average cost
Private JLabel everyCostValue;

Private JButton submitButton;
Private JButton resetButton;

Private JPanel northPanel;
Private JPanel centerPanel;
Private JPanel southPanel;

Private CompareTime CompareTime;//date comparison
Private StringUtil StringUtil;//string tools

Private JCalendarFrame JCalendarFrame;

Private int typee.//date response type 1: start date: 2 end date

Public RentCalculatorFrame () {

Enclosing setBounds (350250450350);

Enclosing setLayout (null);
Calculator enclosing setTitle (" rent ");

NorthPanel=new JPanel ();
CenterPanel=new JPanel ();
SouthPanel=new JPanel ();

NorthPanel. SetBounds (3,5,435,190);
NorthPanel. SetBorder (BorderFactory. CreateTitledBorder (" rental information "));

RentPriceMonth=new JLabel (" rent ");
rentPriceMonthValue=https://bbs.csdn.net/topics/new JTextField (15);

RentPriceMonthValue. AddKeyListener (this);

StartDate=new JLabel (" start date ");
startDateValue=https://bbs.csdn.net/topics/new JTextField (8);
StartDateValue. AddMouseListener (this);

EndDate=new JLabel (" end date ");
endDateValue=https://bbs.csdn.net/topics/new JTextField (8);
EndDateValue. AddMouseListener (this);

EndDateValue. AddKeyListener (this);

RentPersonNums=new JLabel (" Shared personnel ");
rentPersonNumsValue=https://bbs.csdn.net/topics/new JTextField (15);

RentPersonNumsValue. AddKeyListener (this);

PropertyCost=new JLabel (" property fee ");
propertyCostValue=https://bbs.csdn.net/topics/new JTextField (15);

PropertyCostValue. AddKeyListener (this);

Othercost=new JLabel (" other costs ");
otherCostValue=https://bbs.csdn.net/topics/new JTextField (15);

OtherCostValue. AddKeyListener (this);

Box vBox=Box. CreateVerticalBox ();

Box vBox1=Box. CreateHorizontalBox ();
Box hBox1=Box. CreateHorizontalBox ();
HBox1. Add (rentPriceMonth);
HBox1. Add (Box. CreateHorizontalStrut (10));
HBox1. Add (rentPriceMonthValue);
VBox1. Add (hBox1);
VBox1. Add (Box. CreateVerticalStrut (10));

Box vBox2=Box. CreateVerticalBox ();
Box hBox2=Box. CreateHorizontalBox ();
HBox2. Add (startDate);
HBox2. Add (Box. CreateHorizontalStrut (10));
HBox2. Add (startDateValue);
HBox2. Add (Box. CreateHorizontalStrut (10));
HBox2. Add (endDate);
HBox2. Add (Box. CreateHorizontalStrut (10));
HBox2. Add (endDateValue);

VBox2. Add (hBox2);
VBox2. Add (Box. CreateHorizontalStrut (10));

Box vBox3=Box. CreateVerticalBox ();
Box hBox3=Box. CreateHorizontalBox ();
HBox3. Add (rentPersonNums);
HBox3. Add (Box. CreateHorizontalStrut (10));
HBox3. Add (rentPersonNumsValue);
VBox3. Add (hBox3);
VBox3. Add (Box. CreateVerticalStrut (10));

Box vBox4=Box. CreateVerticalBox ();
Box hBox4=Box. CreateHorizontalBox ();
HBox4. Add (propertyCost);
HBox4. Add (Box. CreateHorizontalStrut (10));
HBox4. Add (propertyCostValue);
VBox4. Add (hBox4);
VBox4. Add (Box. CreateVerticalStrut (10));

Box vBox5=Box. CreateVerticalBox ();
Box hBox5=Box. CreateHorizontalBox ();
HBox5. Add (othercost);
HBox5. Add (Box. CreateHorizontalStrut (10));
HBox5. Add (otherCostValue);
VBox5. Add (hBox5);
VBox5. Add (Box. CreateVerticalStrut (10));

The vBox. Add (vBox1);
The vBox. Add (vBox2);
The vBox. Add (vBox3);
The vBox. Add (vBox4);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull