import javax.swing.*;
import java.awt.event.*;
class pan extends JPanel
{ JLabel jl=new JLabel("label");
JButton jb;
pan()
{
setBackground(Color.green);
add(jl);
jb=new JButton("ha");
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jb)
jb.setText("hello");
}
});
add(jb);
}
}
public class inclas3 extends JFrame {
pan p=new pan();
public inclas3() {
this.add(p);
this.setTitle("inclas3!");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
JFrame f=new inclas3();
f.setBounds(100,100,300,300);
f.setVisible(true);
}
}
No comments:
Post a Comment