JAVA25

面板

package Demo02;

import java.awt.Container;
//面板作为容器不能单独存在,必须放到其他容器里面JFrame,jDialog

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JPaneDemo extends JFrame{
	
	public JPaneDemo() {
		
		Container container1=this.getContentPane();
		container1.setLayout(new GridLayout(2,1,10,10));//布局行列,间距
		
		JPanel panel=new JPanel(new GridLayout(1,3));
		panel.add(new JButton("1"));
		panel.add(new JButton("2"));
		panel.add(new JButton("3"));
		
		container1.add(panel);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setBounds(100,100,500,500);
	}
	
	
	
	public static void main(String[] args) {
		new JPaneDemo();
		
	}

}

在这里插入图片描述
文本域

package Demo02;                                                                                                                                     
                                                                                                                                                    
import java.awt.Container;                                                                                                                          
                                                                                                                                                    
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;                                                                                                                          
                                                                                                                                                    
public class JScrollDemo extends JFrame{                                                                                                            
	                                                                                                                                                
	public JScrollDemo() {                                                                                                                          
		                                                                                                                                            
		Container container1=this.getContentPane();   
		
		//文本域
		JTextArea texarea=new JTextArea(20,50);
		texarea.setText("大数据2005");
		

		
		//scroll面板
		JScrollPane scrollpane=new JScrollPane(texarea);
		//JScrollDemo scrollDemo=new JPanel();
		//scrollDemo.add(textarea);
		container1.add(scrollpane);
         
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setBounds(100,100,500,500);
}       
	public static void main(String[] args) {
		new JScrollDemo();
	}
}                                                                                                                                                 

在这里插入图片描述
窗体布局
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值