[基础]JPanel自由布局简介

                contentPane = new JPanel();
		contentPane.setLayout(null);
		
		Toolkit tk = getToolkit();
		Dimension screenSize = tk.getScreenSize();
		int width = (int) (screenSize.width*0.8);
		int height = (int) (screenSize.height*0.8);
		
		searchFrame = new Search_Panel(1);
		searchFrame.setBounds(0,0,(int)(width*0.3),(int)(height*0.3));
		contentPane.add(searchFrame);
		
		infoFrame = new Info_Panel();
		infoFrame.setBounds(0,(int)(height*0.3),(int)(width*0.3),height-(int)(height*0.3));
		contentPane.add(infoFrame);
		
		tableFrame = new Table_Panel();
		tableFrame.setBounds((int)(width*0.3),0,width-(int)(width*0.3),height);
		contentPane.add(tableFrame);
		setContentPane(contentPane);
		setBounds(100, 100, 450, 300);
		setVisible(true);

今天在布局的时候遇到一些问题,java给出的几种默认布局的效果都不是很好,于是参考了一些程序,进行自由布局,示例程序如上

你可能感兴趣的:([基础]JPanel自由布局简介)