所以我有一个问题,我不能解决我想我的GUI应用程序分为3个JPanels(左,中,右)。我希望左侧面板和右侧面板具有固定的大小和中心流动性。意义侧面板仅在JFrame展开时垂直展开,而中央面板则水平和垂直展开漫游器。Java - MigLayout seting界限
我将所有面板的最小尺寸设置为600的高度,但他们只是保持最小尺寸,并且不扩展为JForm增加我不知道如何设置JFrame边框的边界,以便他们扩展它。
package ppe.view;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import net.miginfocom.swing.MigLayout;
public class UI_View extends JFrame
{
private JList browse = new JList();
private JScrollPane rightX = new JScrollPane();
private JButton btn1 = new JButton("Button 1");
private JButton btn2 = new JButton("Button 2");
private JButton btn3 = new JButton("Button 3");
private JButton btn4 = new JButton("Button 4");
public UI_View()
{
this.setTitle("Prototype MVC Arhitecture");
this.setMinimumSize(new Dimension(800, 600));
this.setExtendedState(this.MAXIMIZED_BOTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new MigLayout());
JPanel content = new JPanel(new MigLayout());
content.setBackground(Color.black);
JPanel right = new JPanel(new MigLayout());
JPanel center = new JPanel(new MigLayout());
JPanel left = new JPanel(new MigLayout());
right.setBackground(Color.red);
right.setMinimumSize(new Dimension(200, 600));
right.setMaximumSize(new Dimension(200, 37500));
center.setBackground(Color.green);
center.setMinimumSize(new Dimension(400, 600));
left.setBackground(Color.blue);
left.setMinimumSize(new Dimension(200, 600));
left.setMaximumSize(new Dimension(200, 37500));
content.add(left);
content.add(center);
content.add(right);
this.setContentPane(content);
}
public static void main(String[] args)
{
new UI_View().setVisible(true);
}
}
我已经tryed他们包围另一个内容面板,并补充说,面板的contentPane到JFrame中是自动范围以JFrame的边界,但事情仍然是非常固定。
感谢您的帮助,我在寻找增长的限制,但他们似乎没有帮助。 – 2011-12-29 13:26:22
@kellax,试着用''debug''参数创建你的'MiGLayout'来查看绘制的边框。另外,尝试为中央面板添加'“grow,pushx”'。 – Thomas 2011-12-29 13:29:05
它现在的作品现在左右都是固定的大小和中心。我不得不这样定义它:对于侧面板.add(面板,“growy,pushy”)和中心“grow,pushx” 不完全确定,但我认为“psuhx或pushy”作为额外参数方向扩展,如果你想充分填补空间。 – 2011-12-29 13:50:36