mn cho mình nhờ chút, mình làm xong cái code của bài này rồi, nhưng phần GUI mình k biết làm , ai biết giúp mình vs. Đây là đề: Program Requirements: Using array to develop application that manages bill information for using electricity. · Define “Bill” class that includes: o Attributes: § Customer code § Customer type § Old index of electricity meter § New index of electricity meter 0->500 o Methods: § Initiate the attributes of “Bill” class § Needed accessor methods (getters) and mutator methods (setters) § Calculate used electrical energy (KW) = New index of electricity meter – Old index of electricity meter § Calculate norm using electricity. It is known: Customer Type Norm using electrictity (KW)(định mức sử dụng điện) “NN” 500 “SX” or “KD” 400 otherwise 300 § Calculate payment for using electricity = Used electrical energy * Unit price. It is known: Used electrical energy Unit price If Used electrical energy <= Norm 550 đồng /KW otherwise 1100 đồng / KW o Define array class to manage bill information. Each item in the list has the data type of “Bill” class § Methods of the class: · Add a bill to the list · Find out the bill corresponding with specified bill code · Calculate the total bill payment of customers belonging among specified customer type · Delete the bill corresponding with specified customer code · Find out the bill having largest payment o Define graphics user inteface class that supplies a input and output interface for bill information § When the user selects “Add”, “Find”, “Payment”, “Delete”, “Largest Payment” buttons, the corresponding method defined in the array class is called § Read in bill information, select “Add” button, the bill information is added to the list § Read in bill code, select “Find” button, the information of bill having the bill code is displayed § Read in customer type, select “Payment” button, the total payment of the bills belonging among the customer type is calculated § Read in customer code, select “Delete” button, the corresponding bill is removed from the list § Select “Largest Payment” button, the information of bill having the total largest payment is displayed. Đây là bài mình làm public class Bill { protected double Customer_code; protected String Customer_type; protected double Old_index_of_electricity_meter; protected double New_index_of_electricity_meter; protected double bill_code; public Bill(){ Customer_code=0.0; Customer_type=" "; Old_index_of_electricity_meter=0.0; New_index_of_electricity_meter=0.0; bill_code=0.0; } public Bill(double Customer_code, String Customer_type, double Old_index_of_electricity_meter, double New_index_of_electricity_meter){ this.Customer_code=Customer_code; this.Customer_type=Customer_type; this.Old_index_of_electricity_meter=Old_index_of_electricity_meter; this.New_index_of_electricity_meter=New_index_of_electricity_meter; this.bill_code=bill_code; } public double electrical_energy(){ return New_index_of_electricity_meter-Old_index_of_electricity_meter; } public double norm_using_electricity(String s){ //mức điện nhập vào double norm=0; if(s.equals("NN")) norm=500; else if(s.equals("SX") && s.equals("KD")) norm=400; else norm=300; return norm; } public double payment(){ double payment=0; if(electrical_energy()<=500) payment = 550 * electrical_energy(); else payment= 1100*electrical_energy(); return payment; }@Override public String toString() { return "Bill [Customer_code=" + Customer_code + ", Customer_type="[/COLOR][/SIZE][/SIZE][/COLOR][/B] [B][COLOR=#000000][SIZE=2][SIZE=2][COLOR=#000080]+ Customer_type + ", Old_index_of_electricity_meter="[/COLOR][/SIZE][/SIZE][/COLOR][/B] [B][COLOR=#000000][SIZE=2][SIZE=2][COLOR=#000080]+ Old_index_of_electricity_meter[/COLOR][/SIZE][/SIZE][/COLOR][/B] [B][COLOR=#000000][SIZE=2][SIZE=2][COLOR=#000080]+ ", New_index_of_electricity_meter="[/COLOR][/SIZE][/SIZE][/COLOR][/B] [B][COLOR=#000000][SIZE=2][SIZE=2][COLOR=#000080]+ New_index_of_electricity_meter + ", bill_code=" + bill_code[/COLOR][/SIZE][/SIZE][/COLOR][/B] [B][COLOR=#000000][SIZE=2][SIZE=2][COLOR=#000080]+ "]"; } public double getCustomer_code() { return Customer_code; } public void setCustomer_code(double customer_code) { Customer_code = customer_code; } public String getCustomer_type() { return Customer_type; } public void setCustomer_type(String customer_type) { Customer_type = customer_type; } public double getOld_index_of_electricity_meter() { return Old_index_of_electricity_meter; } public void setOld_index_of_electricity_meter( double old_index_of_electricity_meter) { Old_index_of_electricity_meter = old_index_of_electricity_meter; } public double getNew_index_of_electricity_meter() { return New_index_of_electricity_meter; } public void setNew_index_of_electricity_meter( double new_index_of_electricity_meter) { New_index_of_electricity_meter = new_index_of_electricity_meter; } public double getBill_code() { return bill_code; } public void setBill_code(double bill_code) { this.bill_code = bill_code; } public static void main(String[] args) { Bill b=new Bill(); } } Đây là phần GUI, chưa biết làm thế nào nữa, import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; public class BillGui extends JFrame implements ActionListener,KeyListener{ private JButton bAdd,bFind,bPayment,bDelete,bLargest_Payment; private JLabel lCustomer_code,lCustomer_type,lOld_index,lNew_index,lBill_code ; private JTextField txtCustomer_code,txtCustomer_type,txtOld_index,txtNew_index,txtBill_code; private JPanel p1,p2,p3,p4,p5,p6; public BillGui(){ this.setLayout(new FlowLayout()); this.setTitle("MANAGING BILLS FOR USING ELECTRICITY"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(450,300); this.setLocationRelativeTo(null); this.setVisible(true); lCustomer_code=new JLabel("Customer Code"); txtCustomer_code=new JTextField(10); p1=new JPanel(); p1.setLayout(new FlowLayout()); p1.add(lCustomer_code); p1.add(txtCustomer_code); lCustomer_type=new JLabel("Customer Type"); txtCustomer_type=new JTextField(10); p2=new JPanel(); p2.setLayout(new FlowLayout()); p2.add(lCustomer_type); p2.add(txtCustomer_type); lOld_index=new JLabel("Old index of electricity meter"); txtOld_index=new JTextField(10); p3=new JPanel(); p3.setLayout(new FlowLayout()); p3.add(lOld_index); p3.add(txtOld_index); lNew_index=new JLabel("New index of electricity meter "); txtNew_index=new JTextField(10); p4=new JPanel(); p4.setLayout(new FlowLayout()); p4.add(lNew_index); p4.add(txtNew_index); lBill_code=new JLabel("Bill Code"); txtBill_code=new JTextField(10); p5=new JPanel(); p5.setLayout(new FlowLayout()); p5.add(lBill_code); p5.add(txtBill_code); bAdd=new JButton("Add"); bFind=new JButton("Find"); bPayment=new JButton("Payment"); bDelete=new JButton("Delete"); bLargest_Payment=new JButton("Largest Payment"); p6=new JPanel(); p6.setLayout(new FlowLayout()); p6.add(bAdd); p6.add(bFind); p6.add(bPayment); p6.add(bDelete); p6.add(bLargest_Payment); this.add(p1); this.add(p2); this.add(p3); this.add(p4); this.add(p5); this.add(p6); validate(); bAdd.addActionListener(this); bFind.addActionListener(this); bPayment.addActionListener(this); bDelete.addActionListener(this); bLargest_Payment.addActionListener(this); txtCustomer_code.addKeyListener(this); txtCustomer_type.addKeyListener(this); txtOld_index.addKeyListener(this); txtNew_index.addKeyListener(this); txtBill_code.addKeyListener(this); bAdd.addKeyListener(this); bFind.addKeyListener(this); bPayment.addKeyListener(this); bDelete.addKeyListener(this); bLargest_Payment.addKeyListener(this); } public static void main(String[] args) { BillGui b=new BillGui(); } @Override public void actionPerformed(ActionEvent e) { } @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } } ai qan tâm giúp mình vs, mình cảm ơn nhìu.