Trouble when adding actionListener() to a JPanel
I am trying to add actionListener to a JPanel in swing frame. I want to
create an event when clicking on that particular JPanel. Here is some
slice of code where in stuck down.
JLabel jlab=new JLabel("");
JPanel pnl=new JPanel();
pnl.add(jlab);
JPanel mainpnl=new JPanel();
pnl.addActionListener(new ActionListener(){public void
actionPerformed(ActionEvent ae) {jlab.setText("Clciking !!!");}});
mainpnl.add(pnl);
No comments:
Post a Comment