⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch9_31.java

📁 60多个javaSwing范例
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ch9_31 extends JFrame
{
	public ch9_31()
	{
		setBounds(20,20,500,300);
		getContentPane().setLayout(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);              
	}
	public static void main(String [] args)
	{
		ch9_31 f=new ch9_31();
		f.getContentPane().setLayout(new BorderLayout());
		
		JPanel p1=new JPanel();
		p1.setLayout(new GridLayout(2,2));
		p1.setBorder(BorderFactory.createTitledBorder("事件处理范例"));
		JLabel l1=new JLabel("输入:");
		JLabel l2=new JLabel("输入后,按enter==>");
		final JLabel l3=new JLabel("");
		final JTextField t1=new JTextField();
		t1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				l3.setText(t1.getText());
			}	
		});
		p1.add(l1);
		p1.add(t1);
		p1.add(l2);
		p1.add(l3);
		f.getContentPane().add(p1);
		f.pack();
		f.show();
	}
}
		
		
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -