Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

public class Main {
    /**
     * @param title
     * @param comp 
     * @return jpanel
     */
    public static JPanel createTitledScrollComponent(String title, Component comp) {
        JScrollPane scroll = new JScrollPane(comp);
        scroll.setWheelScrollingEnabled(true);
        scroll.setPreferredSize(new Dimension(1, 1));
        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createTitledBorder(title));
        panel.setLayout(new BorderLayout());
        panel.add(scroll, BorderLayout.CENTER);
        return panel;
    }

    /**
     * @param gx
     * @param gy
     * @param gw
     * @param gh
     * @param wx
     * @param wy
     * @param what
     * @param where
     * @param gbc
     * @param gridbag
     */
    public static void add(int gx, int gy, int gw, int gh, int wx, int wy, Component what, Container where,
            GridBagConstraints gbc, GridBagLayout gridbag) {
        gbc.gridx = gx;
        gbc.gridy = gy;
        gbc.gridwidth = gw;
        gbc.gridheight = gh;
        gbc.weightx = wx;
        gbc.weighty = wy;
        gridbag.setConstraints(what, gbc);
        where.add(what);
    }
}