Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JComponent;

import javax.swing.JPanel;

public class Main {
    private final static int ROW_HEIGHT = 25;

    public static JPanel getComponentColumn(JComponent[] components) {
        JPanel columnPanel = new JPanel();
        columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.PAGE_AXIS));

        for (int i = 0; i < components.length; i++) {
            components[i].setMinimumSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
            components[i].setPreferredSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
            components[i].setMaximumSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
            components[i].setAlignmentX(JComponent.LEFT_ALIGNMENT);
            columnPanel.add(components[i]);
        }
        return columnPanel;
    }
}