View unanswered posts | View active topics It is currently Wed May 24, 2017 5:20 am

Reply to topic  [ 1 post ] 
 MigLayout - How to set bounds to JFrame 
Author Message

Joined: Thu Dec 29, 2011 4:06 pm
Posts: 1
Post MigLayout - How to set bounds to JFrame

Yesterday i discovered MigLayout and have been experimenting whit it and so far its the best
LayoutManager and easiest to understand that i came across, any who .

So i have a problem i cant solve i want my GUI app to be split between 3 JPanels (left, center, right).
I want left panel and right panel to be of fixed size and center to be fluid. Meaning side panels expand only
vertically as JFrame is expanded and center panel expands bot horizontally and vertically.

I have set minimal size for all panels to be height of 600 but they just stay in the minimal size
and dont expand as JForm increases i dont know how to set bounds
to JFrame borders so they expand whit it.

I have tried setting bounds like so but does not work all JPanels just stay fixed i colored them to see if they expand
content.add(left, "growy");
content.add(center, "grow"); //the same as growx, growy
content.add(right, "growy");

Here is my code:
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.setLayout(new MigLayout());

        JPanel content = new JPanel(new MigLayout());

        JPanel right  = new JPanel(new MigLayout());
        JPanel center = new JPanel(new MigLayout());
        JPanel left   = new JPanel(new MigLayout());

        right.setMinimumSize(new Dimension(200, 600));
        right.setMaximumSize(new Dimension(200, 37500));

        center.setMinimumSize(new Dimension(400, 600));

        left.setMinimumSize(new Dimension(200, 600));
        left.setMaximumSize(new Dimension(200, 37500));



    public static void main(String[] args)
        new UI_View().setVisible(true);


Thu Dec 29, 2011 4:11 pm
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.