I want to creat simple aplication which if I click a button it will do something and the value would update on the interface , the value updates but not on the interface
Code:
public class baza { public static void main(String[] args) {derivat f=new derivat("titlu"); f.initializare(); f.show(); } } import java.awt.*; import java.awt.event.*; public class derivat extends Frame implements ActionListener{ private int k=0,a=0; //it's declaration public derivat(String titlu){ super(titlu); } public void initializare(){ setLayout(new GridLayout(2,0)); setSize(900,900); Panel x=new Panel(); x.setLayout(new FlowLayout()); Button b1=new Button("Stand1"); x.add(b1); x.add(new Label("Standuri:"+k)); // where it is called in the code Button b2=new Button("Vanzare1"); x.add(b2); add(x); Panel y=new Panel(); y.setLayout(new FlowLayout()); Button b3=new Button("Stand2"); y.add(b3); y.add(new Label("Standuri:"+a)); Button b4=new Button("Vanzare2"); y.add(b4); add(y); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); } public void actionPerformed(ActionEvent e){ String command=e.getActionCommand(); if (command.equals("Stand1")) ++k; // the value which I update but doesn't show on the interface else if(command.equals("Stand2")) a++; } }
Please help