如题,我还需要加上什么才可以实现?谢谢import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.Icon;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.SwingConstants;class llbb extends JFrame implements ActionListener{ JButton jb; llbb() { JPanel jp=new JPanel(); Icon icon=new ImageIcon("1.png"); jb=new JButton("kafei",icon); jp.add(jb); add(jp); jb.addActionListener(this); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub Icon icon=new ImageIcon("2.png"); jb.setIcon(icon); jb.setText("qq"); } }public class ex02 { public static void main(String[] args) { // TODO Auto-generated method stub llbb f=new llbb(); f.setTitle("图标"); f.setSize(200,150); f.setLocation(400,300); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }}
1 回答
添加回答
举报
0/150
提交
取消