View unanswered posts | View active topics It is currently Fri May 26, 2017 5:55 pm



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
Hi,

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
correctly:
Quote:
content.add(left, "growy");
content.add(center, "grow"); //the same as growx, growy
content.add(right, "growy");


Here is my code:
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.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);
    }

}


Thu Dec 29, 2011 4:11 pm
Profile
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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.