package 常用组件及布局;public class Mainwind { public static void main(String[] args) {
// TODO Auto-generated method stub
Haha win=new Haha();
}}package 常用组件及布局;import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;public class Haha extends JFrame {
 JButton b1,b2;
 JLabel a1=new JLabel();
public Haha() {
setTitle("图形用户界面");
setSize(460,300);
setLocation(100,100);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b1=new JButton("中文");
b2=new JButton("English");
JPanel cp=new JPanel();
cp.add(b1);
cp.add(b2);
a1.setOpaque(true);
a1.setBackground(Color.YELLOW);
a1.setText("你好,中国");
Container con=getContentPane();
con.add(cp,BorderLayout.NORTH);
con.add(a1,BorderLayout.CENTER);
b1.addActionListener(new b11());
b2.addActionListener(new hah());
con.validate();


}


}
package 常用组件及布局;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JLabel;public class b11 implements ActionListener {
JLabel a1;
JButton b1;
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
a1.setText("你好吗");
}}package 常用组件及布局;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JLabel;public class hah implements ActionListener {
JLabel a1;
JButton b2;
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
a1.setText("english"); }}