Hey guys,
i am quite new to Java and i just started learning this ActionEvent and im getting semicolons errors.
mind to help me?
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class LongDistanceCall extends JFrame implements ActionListener { JLabel lbl1,lbl2,lbl3,lbl4; JTextField tf1,tf2,tf3; JRadioButton rb1,rb2,rb3; JPanel p1,p2,p3,p4,p5; rb1.add ActionListener(this); rb2.add ActionListener(this); rb3.add ActionListener(this); public static void main (String [] arg) { LongDistanceCall fr = new LongDistanceCall(); fr.setSize(300,250);//pack(); fr.setVisible(true); fr.setTitle("Long Distance Call"); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public LongDistanceCall() { lbl1 = new JLabel("Enter hours of the call:"); lbl2 = new JLabel("Enter Minutes of the call:"); lbl3 = new JLabel("Rate Category:"); lbl4 = new JLabel("Charges for the call:RM"); tf1 = new JTextField(5); tf2 = new JTextField(5); tf3 = new JTextField(5); rb1 = new JRadioButton("Daytime (6am - 5.59am)"); rb2 = new JRadioButton("Evening (6pm - 11.59pm)"); rb3 = new JRadioButton("off-Peak (12am - 5.59am)"); p1 = new JPanel(); p1.setLayout(new GridLayout(1,2)); p1.add(lbl1); p1.add(tf1); p2 = new JPanel(); p2.setLayout(new GridLayout(1,2)); p2.add(lbl2); p2.add(tf2); p3 = new JPanel(); p3.setLayout(new GridLayout(1,2)); p3.add(lbl3); p4 = new JPanel(); p4.setLayout(new GridLayout(3,2)); p4.add(rb1); p4.add(rb2); p4.add(rb3); p5 = new JPanel(); p5.add(lbl4); p5.add(tf3); setLayout(new GridLayout(5,1)); add(p1); add(p2); add(p3); add(p4); add(p5); } public void ActionPerformed(Action Event.e)) { double hours = Double parseDouble(tf1.getText()); double minutes = Double parseDouble(tf2.getText()); double rate = 0; if(e.getSource() == rb1) { rate = 0.07; } if(e.getSource() == rb2) { rate = 0.12; } if(e.getSource() == rb3) { rate = 0.05; } double duration = (hours*60)+(minutes); double total = duration * rate; tf3.setText(String ValueOf(total)); } }
Hope to get help
thnx!