New to using jswing just wondering how to make a button that has some calculation to display a text on a label? Like 3 buttons that holds 3 different value and then have a Calculate button that displays the result to a label?
JRadioButton rdbtnNewRadioButton = new JRadioButton("Single");
rdbtnNewRadioButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TotalPay = TotalPay + Single;
}
JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("Two or more");
rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TotalPay = TotalPay + two;
}
});
JRadioButton rdbtnWithPet = new JRadioButton("With Pet");
rdbtnWithPet.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TotalPay = TotalPay + Pet;
}
});
JButton btnNewButton = new JButton("Calculate");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//What code to insert to display label result?
}
});
JLabel lblNewLabel_2 = new JLabel(""); //result of the total must display here?
lblNewLabel_2.setBounds(232, 47, 110, 69);
frmPaulasPortraits.getContentPane().add(lblNewLabel_2);