usr/src/java/vpanels/app/usermgr/com/oracle/solaris/vp/panels/usermgr/client/swing/Constraints.java
author Stephen Talley <stephen.talley@oracle.com>
Fri, 27 Apr 2012 00:52:26 -0400
changeset 847 a8e124b894b8
permissions -rw-r--r--
7095663 A GUI needed for User Management 7158462 modify RAD usermgr module to support user/role cmds functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
847
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     1
/*
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     2
 * CDDL HEADER START
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     3
 *
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     7
 *
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    11
 * and limitations under the License.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    12
 *
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    18
 *
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    19
 * CDDL HEADER END
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    20
 */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    21
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    22
/*
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    23
 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    24
 */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    25
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    26
package com.oracle.solaris.vp.panels.usermgr.client.swing;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    27
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    28
import java.applet.*;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    29
import java.awt.*;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    30
import java.lang.*;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    31
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    32
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    33
/**
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    34
 * SMC code adapted for Visual Panels
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    35
 *
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    36
 * A general utility class to make it easy to apply GridBagConstraints
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    37
 * to GridBagLayout.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    38
 * Code lifted from "Java in a Nutshell", O'Reilly & Associated, Inc.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    39
 * and wrapped in a final class.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    40
 */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    41
public final class Constraints {
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    42
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    43
    /**
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    44
     * This is the main constrain() method.  It has arguments for
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    45
     * all constraints.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    46
     */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    47
    public static void constrain(
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    48
	    Container	container,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    49
	    Component	component,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    50
	    int 	gridx,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    51
	    int 	gridy,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    52
	    int 	gridwidth,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    53
	    int 	gridheight,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    54
	    int 	fill,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    55
	    int 	anchor,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    56
	    double	weightx,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    57
	    double	weighty,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    58
	    int 	top,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    59
	    int 	left,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    60
	    int 	bottom,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    61
	    int 	right)
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    62
    {
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    63
	GridBagConstraints gbc = new GridBagConstraints();
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    64
	gbc.gridx = gridx;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    65
	gbc.gridy = gridy;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    66
	gbc.gridwidth = gridwidth;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    67
	gbc.gridheight = gridheight;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    68
	gbc.fill = fill;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    69
	gbc.anchor = anchor;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    70
	gbc.weightx = weightx;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    71
	gbc.weighty = weighty;
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    72
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    73
	if (top+bottom+left+right > 0)
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    74
	    gbc.insets = new Insets(top, left, bottom, right);
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    75
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    76
	((GridBagLayout)container.getLayout()).setConstraints(component, gbc);
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    77
	container.add(component);
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    78
    }
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    79
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    80
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    81
    /**
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    82
     * This version of constrain() specifies the position of a component
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    83
     * that does not grow and does not have margins.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    84
     */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    85
    public static void constrain(
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    86
	    Container	container,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    87
	    Component	component,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    88
	    int 	gridx,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    89
	    int 	gridy,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    90
	    int 	gridwidth,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    91
	    int 	gridheight)
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    92
    {
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    93
	constrain(container, component,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    94
	    gridx, gridy, gridwidth, gridheight,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    95
	    GridBagConstraints.NONE, GridBagConstraints.NORTHWEST,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    96
	    0.0, 0.0, 0, 0, 0, 0);
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    97
    }
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    98
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
    99
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   100
    /**
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   101
     * This version of constrain() specifies the position of a component
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   102
     * that does not grow but does have margins.
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   103
     */
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   104
    public static void constrain(
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   105
	    Container	container,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   106
	    Component	component,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   107
	    int 	gridx,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   108
	    int 	gridy,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   109
	    int 	gridwidth,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   110
	    int 	gridheight,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   111
	    int 	top,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   112
	    int 	left,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   113
	    int 	bottom,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   114
	    int 	right)
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   115
    {
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   116
	constrain(container, component,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   117
	    gridx, gridy, gridwidth, gridheight,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   118
	    GridBagConstraints.NONE, GridBagConstraints.NORTHWEST,
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   119
	    0.0, 0.0, top, left, bottom, right);
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   120
    }
a8e124b894b8 7095663 A GUI needed for User Management
Stephen Talley <stephen.talley@oracle.com>
parents:
diff changeset
   121
}