1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
public class Interface extends ExitableJFrame {
// begin
static JPanel UpperPane= new JPanel();
static JPanel CentralPane=new JPanel();
static JPanel ButtomPane=new JPanel();
//elements
static JTextField text1=new JTextField(" ");
static JTextField text2=new JTextField(" ");
static JTextField text3=new JTextField(" ");
static JTextField text8=new JTextField(" ");
static JTextField text9=new JTextField(" ");
static JTextField text6=new JTextField(" ");
static JTextField text7=new JTextField(" ");
static JTextField text4=new JTextField(" ");
static JTextField text5=new JTextField(" ");
static JButton button1=new JButton("Get");
static JButton button2=new JButton("Save");
static JButton button3=new JButton("Print Report");
static JButton button4=new JButton("Clear");
static JButton button5=new JButton("Exit");
static JLabel label1=new JLabel("Month");
static JLabel label2=new JLabel("Year");
static JLabel label3=new JLabel("Income");
static JLabel label4=new JLabel("Current Balance");
static JLabel label5=new JLabel("Status");
static JLabel label6=new JLabel("Extra Income");
static JLabel label7=new JLabel("Daily Transactions");
static JLabel label8=new JLabel("Loans");
static JLabel label9=new JLabel("Others");
//borders
static Border UpperBord=BorderFactory.createTitledBorder("Summary");
static Border CentralBord=BorderFactory.createTitledBorder("Transactions");
static Border ButtomBord=BorderFactory.createTitledBorder("Board");
//Listener Platform
static class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
System.exit(0);}
}
static class MyActionListener1 implements ActionListener {
public void actionPerformed(ActionEvent event){
text1.setText("");text2.setText("");text3.setText("");text4.setText("");
text5.setText("");text6.setText("");text7.setText("");text8.setText("");
text9.setText("");}
}
public static void GetBalance() {
double v1=Double.parseDouble(text3.getText());
double v2=Double.parseDouble(text6.getText());
double v3=Double.parseDouble(text7.getText());
double v4=Double.parseDouble(text4.getText());
double v5=Double.parseDouble(text5.getText());
double r=0;
r=v1+v2-v3-v4-v5;
text8.setText(""+r);
if(r<0)text9.setText("Debit");
if(r>0)text9.setText("Credit");
if(r==0)text9.setText("N/A");
}
static class MyActionListener2 implements ActionListener{
public void actionPerformed(ActionEvent event){
GetBalance();
}
}
public static void main(String[] args) {
System.out.print("fdgfdgfd");
ExitableJFrame MainFrame=new ExitableJFrame();
UpperPane.setBorder(UpperBord);
UpperPane.setLayout(new FlowLayout());
UpperPane.add(label1);
UpperPane.add(text1);
UpperPane.add(label2);
UpperPane.add(text2);
UpperPane.add(label3);
UpperPane.add(text3);
UpperPane.add(label4);
UpperPane.add(text8);
UpperPane.add(label5);
UpperPane.add(text9);
CentralPane.setBorder(CentralBord);
CentralPane.setLayout(new FlowLayout());
CentralPane.add(label6);
CentralPane.add(text6);
CentralPane.add(label7);
CentralPane.add(text4);
CentralPane.add(label9);
CentralPane.add(text5);
ButtomPane.setBorder(ButtomBord);
ButtomPane.setLayout(new FlowLayout());
ButtomPane.add(button1);
ButtomPane.add(button2);
ButtomPane.add(button3);
ButtomPane.add(button4);
ButtomPane.add(button5);
MainFrame.getContentPane().add(UpperPane, BorderLayout.NORTH);
MainFrame.getContentPane().add(CentralPane, BorderLayout.CENTER);
MainFrame.getContentPane().add(ButtomPane, BorderLayout.SOUTH);
// Closing event
ActionListener event1=new MyActionListener();
button5.addActionListener(event1);
//Clearing Event
ActionListener event2=new MyActionListener1();
button4.addActionListener(event2);
//Getting Balance
ActionListener event3=new MyActionListener2();
button1.addActionListener(event3);
MainFrame.setSize(1024, 400);
MainFrame.show();
}
}
Merci :D |
Partager