All Downloads are FREE. Search and download functionalities are using the official Maven repository.

acm.gui.TablePanel Maven / Gradle / Ivy

Go to download

This the original Stanford Karel for Java, packaged for Maven. ACM Library is included. See also https://cs.stanford.edu/people/eroberts/karel-the-robot-learns-java.pdf

The newest version!
/*
 * @(#)TablePanel.java   1.99.1 08/12/08
 */

// ************************************************************************
// * Copyright (c) 2008 by the Association for Computing Machinery        *
// *                                                                      *
// * The Java Task Force seeks to impose few restrictions on the use of   *
// * these packages so that users have as much freedom as possible to     *
// * use this software in constructive ways and can make the benefits of  *
// * that work available to others.  In view of the legal complexities    *
// * of software development, however, it is essential for the ACM to     *
// * maintain its copyright to guard against attempts by others to        *
// * claim ownership rights.  The full text of the JTF Software License   *
// * is available at the following URL:                                   *
// *                                                                      *
// *          http://www.acm.org/jtf/jtf-software-license.pdf             *
// *                                                                      *
// ************************************************************************

// REVISION HISTORY
//
// -- V2.0 --
// Feature enhancement 26-May-08 (ESR)
//   1. Added support for serialization.

package acm.gui;

import javax.swing.*;

/* Class: TablePanel */
/**
 * This class represents a simple JPanel that uses
 * TableLayout as its layout manager.
 * The purpose of TablePanel is to support tabular component
 * structures without the complexity of the GridBagLayout class.
 */
public class TablePanel extends JPanel {

/** Do not resize component */
	public static final int NONE = TableLayout.NONE;

/** Resize component in horizontal direction only */
	public static final int HORIZONTAL = TableLayout.HORIZONTAL;

/** Resize component in vertical direction only */
	public static final int VERTICAL = TableLayout.VERTICAL;

/** Resize component in both directions */
	public static final int BOTH = TableLayout.BOTH;

/** Center table in the container */
	public static final int CENTER = TableLayout.CENTER;

/** Align table horizontally at the left of its container */
	public static final int LEFT = TableLayout.LEFT;

/** Align table horizontally at the right of its container */
	public static final int RIGHT = TableLayout.RIGHT;

/** Align table vertically at the top of its container */
	public static final int TOP = TableLayout.TOP;

/** Align table vertically at the bottom of its container */
	public static final int BOTTOM = TableLayout.BOTTOM;

/** Expand table to fill its container */
	public static final int FILL = TableLayout.FILL;

/* Package private constructor: TablePanel() */
/**
 * Creates a new TablePanel without assigning a layout manager.
 * This constructor is used only within the acm.gui package.
 */
	TablePanel() {
		/* Empty */
	}

/* Constructor: TablePanel(rows, columns) */
/**
 * Creates a new TablePanel whose layout manager supports the
 * specified number of rows and columns.
 *
 * Example: TablePanel panel = new TablePanel(rows, columns);
 * @param rows The number of rows, or 0 for no limit
 * @param columns The number of columns, or 0 for no limit
 */
	public TablePanel(int rows, int columns) {
		this(rows, columns, 0, 0);
	}

/* Constructor: TablePanel(rows, columns, hgap, vgap) */
/**
 * Creates a new TablePanel with the  specified number
 * of rows and columns and the supplied values for the horizontal and
 * vertical gap.
 *
 * Example: TablePanel panel = new TablePanel(rows, columns, hgap, vgap);
 * @param rows The number of rows, or 0 for no limit
 * @param columns The number of columns, or 0 for no limit
 * @param hgap The gap between columns
 * @param vgap The gap between rows
 */
	public TablePanel(int rows, int columns, int hgap, int vgap) {
		setLayout(new TableLayout(rows, columns, hgap, vgap));
	}

/* Method: setHorizontalAlignment(align) */
/**
 * Sets the horizontal alignment for the table.  The legal values
 * are CENTER, LEFT, RIGHT, and
 * FILL.
 *
 * Example: layout.setHorizontalAlignment(align);
 * @param align The horizontal alignment for the table
 */
	public void setHorizontalAlignment(int align) {
		((TableLayout) getLayout()).setHorizontalAlignment(align);
	}

/* Method: getHorizontalAlignment() */
/**
 * Returns the horizontal alignment for the table.
 *
 * Example: align = layout.getHorizontalAlignment();
 * @return The horizontal alignment for the table
 */
	public int getHorizontalAlignment() {
		return ((TableLayout) getLayout()).getHorizontalAlignment();
	}

/* Method: setVerticalAlignment(align) */
/**
 * Sets the vertical alignment for the table.  The legal values
 * are CENTER, TOP, BOTTOM, and
 * FILL.
 *
 * Example: layout.setVerticalAlignment(align);
 * @param align The vertical alignment for the table
 */
	public void setVerticalAlignment(int align) {
		((TableLayout) getLayout()).setVerticalAlignment(align);
	}

/* Method: getVerticalAlignment() */
/**
 * Returns the vertical alignment for the table.
 *
 * Example: align = layout.getVerticalAlignment();
 * @return The vertical alignment for the table
 */
	public int getVerticalAlignment() {
		return ((TableLayout) getLayout()).getVerticalAlignment();
	}

/* Method: setDefaultFill(fill) */
/**
 * Sets the default fill parameter for components in the table.  The legal values
 * are NONE, HORIZONTAL, VERTICAL, and
 * BOTH.
 *
 * Example: layout.setDefaultFill(fill);
 * @param fill The default fill parameter for components in the table
 */
	public void setDefaultFill(int fill) {
		((TableLayout) getLayout()).setDefaultFill(fill);
	}

/* Method: getDefaultFill() */
/**
 * Returns the default fill parameter for components in the table.
 *
 * Example: fill = layout.getDefaultFill();
 * @return The default fill parameter for components in the table
 */
	public int getDefaultFill() {
		return ((TableLayout) getLayout()).getDefaultFill();
	}

/* Method: setHgap(pixels) */
/**
 * Sets the horizontal gap between components.
 * @param pixels The gap between components in pixels
 */
	public void setHgap(int pixels) {
		((TableLayout) getLayout()).setHgap(pixels);
	}

/* Method: getHgap() */
/**
 * Returns the horizontal gap between components.
 * @return The horizontal gap between components
 */
	public int getHgap() {
		return ((TableLayout) getLayout()).getHgap();
	}

/* Method: setVgap(pixels) */
/**
 * Sets the vertical gap between components.
 * @param pixels The gap between components in pixels
 */
	public void setVgap(int pixels) {
		((TableLayout) getLayout()).setVgap(pixels);
	}

/* Method: getVgap() */
/**
 * Returns the vertical gap between components.
 * @return The vertical gap between components
 */
	public int getVgap() {
		return ((TableLayout) getLayout()).getVgap();
	}

/* Serial version UID */
/**
 * The serialization code for this class.  This value should be incremented
 * whenever you change the structure of this class in an incompatible way,
 * typically by adding a new instance variable.
 */
	static final long serialVersionUID = 1L;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy