editer un label java code example
Example: editer un label java
public class inter extends JFrame implements ActionListener{
JTextField j;
JButton b;
JLabel l;
public inter(){
l=new JLabel("the worst area");
b=new JButton("changer");
b.addActionListener(this);
j=new JTextField(20);
j.setVisible(true);
this.setLayout(new FlowLayout());
this.add(l);
this.add(j);
this.add(b);
l=new JLabel("the worst area");
this.setTitle("diagnostic");
this.setSize(300, 300);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getSource()==b){
this.l.setText(j.getText());
}
}
}