I am trying to use window builder to code this simple task, however, eclipse always says its wrong and doesn't execute. Please what is the mistake on this code? *all the packages are imported. Hello, I am trying to use window builder to code this simple task, however, eclipse always says its wrong and doesn't execute. Please what is the mistake on this code? *all the packages are imported.
private JPanel contentPane;
private JTextField nota_periodo1;
private JTextField nota_periodo2;
private JTextField nota_periodo3;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Ventana1 frame = new Ventana1();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
* @return
*/
public Ventana1() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBackground(new Color(176, 224, 230));
contentPane.setForeground(new Color(176, 224, 230));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblCalculadoraDeNotas = new JLabel("CALCULADORA DE NOTAS SGS");
lblCalculadoraDeNotas.setBounds(146, 20, 200, 16);
contentPane.add(lblCalculadoraDeNotas);
JLabel lblNewLabel = new JLabel("Nota Periodo I:");
lblNewLabel.setBounds(20, 60, 104, 16);
contentPane.add(lblNewLabel);
nota_periodo1 = new JTextField();
nota_periodo1.setBounds(118, 55, 130, 26);
contentPane.add(nota_periodo1);
nota_periodo1.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("Nota Periodo 2:");
lblNewLabel_1.setBounds(20, 88, 104, 16);
contentPane.add(lblNewLabel_1);
JLabel lblNotaPeriodo = new JLabel("Nota Periodo 3:");
lblNotaPeriodo.setBounds(20, 113, 104, 16);
contentPane.add(lblNotaPeriodo);
nota_periodo2 = new JTextField();
nota_periodo2.setBounds(128, 83, 130, 26);
contentPane.add(nota_periodo2);
nota_periodo2.setColumns(10);
nota_periodo3 = new JTextField();
nota_periodo3.setBounds(118, 108, 130, 26);
contentPane.add(nota_periodo3);
nota_periodo3.setColumns(10);
// OBJETO DE INICIO
Ventana1 start = new Ventana1();
String principio = start.Inicio();
JButton calcular = new JButton("Calcular");
calcular.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(principio);
}
});
calcular.setBounds(40, 159, 104, 29);
contentPane.add(calcular);
JLabel lblUstedTieneQue = new JLabel("Usted Tiene que Sacar: ");
lblUstedTieneQue.setBounds(23, 200, 157, 16);
contentPane.add(lblUstedTieneQue);
JLabel nota_examen_final = new JLabel("");
nota_examen_final.setBounds(172, 200, 61, 16);
contentPane.add(nota_examen_final);
JLabel lblEnElExamen = new JLabel("en el Examen Final");
lblEnElExamen.setBounds(245, 200, 124, 16);
contentPane.add(lblEnElExamen);
}
//METODO INICIO
public String Inicio (){
int nota1 = Integer.parseInt(nota_periodo1.getText());
int nota2 = Integer.parseInt(nota_periodo2.getText());
int nota3 = Integer.parseInt(nota_periodo3.getText());
double nota1p = nota1*0.35;
double nota2p = nota2*0.25;
double nota3p = nota3*0.2;
double notapass = 60-(nota1p+nota2p+nota3p);
double notaex = notapass/0.2;
JOptionPane.showMessageDialog(null, notaex);
return null;
}