Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2012 Marco Ratto
 *
 * This file is part of the project MQJExplorer.
 *
 * MQJExplorer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * MQJExplorer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MQJExplorer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.awt.*;
import java.awt.event.ComponentEvent;

public class Main {
    public static void constrainResize(ComponentEvent componentevent) {
        Component component = componentevent.getComponent();
        Dimension dimension = component.getSize();
        Dimension dimension1 = component.getMinimumSize();
        Dimension dimension2 = new Dimension(dimension);
        boolean flag = false;
        if (dimension.width < dimension1.width) {
            flag = true;
            dimension2.width = dimension1.width;
        }
        if (dimension.height < dimension1.height) {
            flag = true;
            dimension2.height = dimension1.height;
        }
        if (flag)
            component.setSize(dimension2);
    }
}