How To Add A number of Textbox Values And Displaying Their Sum In Java. How can we add a number of textboxes information and present their end in an different textbox utilizing GUI or utilizing a button.
- Use TextField to Enter a number of information in Java
- Get Values from A number of textbox
- Java GUI use one button to add a number of textual content fields to a textual content file
- how one can insert worth in a number of textual content field in java
import java.awt.; import java.awt.occasion.;
class kframe extends Body implements ActionListener
{
Checkbox pizza,pepsi,salad;
Label amount,complete;
TextField q1,q2,q3,t1;
Button calculate;
kframe()
{
tremendous("Place Your Order");
setBounds(150,150,320,310);
setBackground(new Shade(55,105,155));
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
setLayout(null);
salad=new Checkbox("SALAD = 50");
salad.setBounds(40,110,130,35);
salad.setFont(new Font("Monotype Corsiva",Font.BOLD,20));
q1=new TextField(35);
q1.setBounds(180,75,100,25);
q1.setFont(new Font("Monotype Corsiva",Font.BOLD,20));
q1.setText("1");
q3=new TextField(35);
q3.setBounds(180,145,100,25);
q3.setFont(new Font("Monotype Corsiva",Font.BOLD,20));
q3.setText("1");
amount=new Label("QUANTITY ");
amount.setBounds(180,40,130,25);
amount.setFont(new Font("Monotype Corsiva",Font.BOLD,20));
calculate=new Button("Calculate ");
calculate.setBounds(100,250,100,25);
calculate.setBackground(new Shade(55,255,55));
calculate.setFont(new Font("Monotype Corsiva",Font.BOLD,20));
calculate.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
int t=0,f=0;
String str=" ";
if(ae.getSource()==calculate)
{
if(pizza.getState())
t=t+(500Integer.parseInt(q1.getText()));
if(pepsi.getState())
t=t+(50Integer.parseInt(q2.getText()));
if(salad.getState())
t=t+(50*Integer.parseInt(q3.getText()));
t1.setText(str.valueOf(t));
}
}
}
class b4
{
public static void major(String str[])
{
kframe f=new kframe();
}
}