📄 subpanel.java,v
字号:
head 1.3;access;symbols;locks; strict;comment @# @;1.3date 2005.05.24.16.20.02; author rirwin; state Exp;branches;next 1.2;1.2date 2005.03.12.00.17.10; author patil; state Exp;branches;next 1.1;1.1date 2004.12.28.00.04.32; author patil; state Exp;branches;next ;desc@@1.3log@fixed javadoc comments.@text@/** *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; }}@1.2log@comments to changed to Java Documentation.@text@d4 1d44 1a44 6 * method: SubPanel * * @@param none * @@return none * * constructor sets border, background properties, layout managerd61 4d67 7a73 7 * @@param Container container: (input) container to place the component * @@param Component component: (input) the component to be constrained * @@param int grid_x: (input) horizontal position of component * @@param int grid_y: (input) vertical position of component * @@param int grid_width: (input) number of horizontal grid spots to take * @@param int grid_height: (input) number of vertical grid spots to take * @@param int fill: (input) directions to fill when d75 1a75 1 * @@param int anchor: (input) anchor position when d77 3a79 3 * @@param double weight_x: (input)relative amount of horizontal space * @@param component should take when its space is resized * @@param double weight_y: (input) relative amount of vertical d81 4a84 4 * @@param int top: (input) amount of inset space on top * @@param int left: (input) amount of inset space on left * @@param int bottom: (input) amount of inset space on bottom * @@param int right: (input) amount of inset space on rightd86 1a86 7 * @@return boolean flag indicating status * * 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. *@1.1log@Initial revision@text@d1 4a4 2// file: SubPanel.java//d15 10a24 7// class: SubPanel//// creates a framed panel with layout type of GridBagLayout//// hierarchy: JPanel->SubPanel//class SubPanel extends JPanel {d42 11a52 9 // method: SubPanel // // arguments: none // returns : none // // constructor sets border, background properties, layout manager // SubPanel() { d64 30a93 27 // method: constrain // // argument: // Container container: (input) container to place the component // Component component: (input) the component to be constrained // int grid_x: (input) horizontal position of component // int grid_y: (input) vertical position of component // int grid_width: (input) number of horizontal grid spots to take // int grid_height: (input) number of vertical grid spots to take // int fill: (input) directions to fill when component space is resized // int anchor: (input) anchor position when component space is resized // double weight_x: (input)relative amount of horizontal space // component should take when its space is resized // double weight_y: (input) relative amount of vertical space component // should take when its space is resized // int top: (input) amount of inset space on top // int left: (input) amount of inset space on left // int bottom: (input) amount of inset space on bottom // int right: (input) amount of inset space on right // // returns: boolean flag indicating status // // 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. //d95 6a100 5 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) { a131 3//// end of file@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -