import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

class TouChaCol{
    JFrame frame;
    JLabel label;
    
    public static void main(String [] args){
        TouChaCol ch = new TouChaCol();
        ch.go();
    }
    
    class LabelActionListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            label.setText("fuck you click me");
        }
    }
    
    class ColorActionListener implements ActionListener{
        public void actionPerformed(ActionEvent e){
            frame.repaint();
        }
    }
    
    public void go(){
        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        Panel panel = new Panel();
        
        label = new JLabel("yoooyo helllo who are you");
        JButton button1 = new JButton("change the color");
        button1.addActionListener(new ColorActionListener());
        
        JButton button2 = new JButton("change the label");
        button2.addActionListener(new LabelActionListener());
        
        frame.getContentPane().add(BorderLayout.SOUTH,button1);
        frame.getContentPane().add(BorderLayout.EAST,button2);
        frame.getContentPane().add(BorderLayout.WEST,label);
        frame.getContentPane().add(BorderLayout.CENTER,panel);
        
        frame.setSize(700, 700);
        frame.setVisible(true);
    }
}
View TouChaCol

相关文章:

  • 2022-03-01
  • 2022-02-05
  • 2021-10-12
  • 2021-04-01
  • 2021-05-12
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案