⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subpanel.java

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA
字号:
/**  *file: SubPanel.java * * last edited: Ryan Irwin */// import necessary java libraries//import java.awt.*;import javax.swing.*;//These imports are not needed - Phil T. 6-23-03//import java.applet.*;//import java.awt.event.*;/** * class: SubPanel * * creates a framed panel with layout type of GridBagLayout * *  hierarchy: JPanel->SubPanel * */class SubPanel extends JPanel {        // *********************************************************************    //    // declare global variables and components    //    // *********************************************************************    // declare global variables    //    public GridBagLayout gridbag = new GridBagLayout();        // *********************************************************************    //    // declare class constructors    //    // *********************************************************************       /**     * Constructor sets border, background properties, layout manager     *     */    SubPanel()     {	super();		this.setLayout(gridbag);    }        // *********************************************************************    //    // declare class methods    //    // *********************************************************************        /**     * This method creates the constraints of a component in a container     * and then adds the component to the container.  it is based on      * code from "Java in a Nutshell" by David Flanagan. published by     * O'Reilly and Associates incorporated.     * method: constrain     *     * @param   container (input) container to place the component     * @param   component (input) the component to be constrained     * @param   grid_x (input) horizontal position of component     * @param   grid_y (input) vertical position of component     * @param   grid_width (input) number of horizontal grid spots to take     * @param   grid_height (input) number of vertical grid spots to take     * @param   fill (input) directions to fill when      *          component space is resized     * @param   anchor (input) anchor position when      *          component space is resized     * @param   weight_x (input)relative amount of horizontal space      *          component should take when its space is resized     * @param   weight_y (input) relative amount of vertical      *          space component should take when its space is resized     * @param   top (input) amount of inset space on top     * @param   left (input) amount of inset space on left     * @param   bottom (input) amount of inset space on bottom     * @param   right (input) amount of inset space on right     *      * @return  true     */    public boolean constrain(Container container, Component component, 			     int grid_x, int grid_y, 			     int grid_width, int grid_height, 			     int fill, int anchor, 			     double weight_x, double weight_y, 			     int top, int left, int bottom, int right)     {	// set the constraints based on the input variables	//	GridBagConstraints c = new GridBagConstraints();	c.gridx = grid_x;	c.gridy = grid_y;	c.gridwidth = grid_width;	c.gridheight = grid_height;	c.fill = fill;	c.anchor = anchor;	c.weightx = weight_x;	c.weighty = weight_y;		// if any of the buffer insets are greater than zero, create a new	// Insets object	//	if (top + bottom + left + right > 0)	    c.insets = new Insets(top, left, bottom, right);		// set the constraints of the component	//	((GridBagLayout) container.getLayout()).setConstraints(component, c);		// add the component to the container	//	container.add(component);		// exit gracefully	//	return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -