home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 4.0 KB | 190 lines |
- /* $Id: gridPanel.java,v 1.4 1996/03/28 08:48:44 djun Exp $
-
- File: gridPanel.java
-
- This is an extension of Panel, with a GridbagLayout and
- constructor methods for common Widgets such as labels,
- buttons, textfields, etc, defined.
-
- Author: Djun M. Kim
- Copyright (c) 1996 Djun M. Kim. All rights reserved.
-
- */
-
- import java.awt.*;
- import java.net.*;
- import java.util.*;
-
- public class gridPanel extends Panel{
-
- // display panel with gridbag layout methods
-
- int RELA = GridBagConstraints.RELATIVE;
- int REMN = GridBagConstraints.REMAINDER;
-
- GridBagLayout gridbag = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
-
- gridPanel() {
- setLayout(gridbag);
- c.fill = GridBagConstraints.BOTH;
- c.ipadx = 0; c.ipady = 0;
- c.insets.top = 0; c.insets.bottom = 0;
- }
-
- gridPanel(Container target) {
- setLayout(gridbag);
- target.add(this);
- c.fill = GridBagConstraints.BOTH;
- c.ipadx = 0; c.ipady = 0;
- c.insets.top = 0; c.insets.bottom = 0;
- }
-
- gridPanel(String s, Container target) {
- setLayout(gridbag);
- target.add(s, this);
- c.fill = GridBagConstraints.BOTH;
- c.ipadx = 0; c.ipady = 0;
- c.insets.top = 0; c.insets.bottom = 0;
- }
-
- public Button make_button(
- String name,
- double weightx, double weighty,
- int gridweight, int gridheight) {
-
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridweight;
- c.gridheight = gridheight;
-
- Button button = new Button(name);
- gridbag.setConstraints(button, c);
- add(button);
- return button;
- }
-
- public Button make_button(
- String name,
- int gridx, int gridy,
- double weightx, double weighty,
- int gridweight, int gridheight) {
-
- c.gridx = gridx;
- c.gridy = gridy;
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridweight;
- c.gridheight = gridheight;
-
- Button button = new Button(name);
- gridbag.setConstraints(button, c);
- add(button);
- return button;
- }
-
- public Label make_label(
- String name,
- double weightx, double weighty,
- int gridwidth, int gridheight) {
-
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridwidth;
- c.gridheight = gridheight;
-
- Label label = new Label(name);
- gridbag.setConstraints(label, c);
- add(label);
- return label;
- }
-
- // Create a text field.
- public TextField make_textf(
- String name,
- boolean editable,
- double weightx, double weighty,
- int gridweight, int gridheight) {
-
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridweight;
- c.gridheight = gridheight;
-
- TextField textf = new TextField(name);
- textf.setEditable(editable);
- gridbag.setConstraints(textf, c);
- add(textf);
- return(textf);
- }
-
- public TextArea make_texta(
- String name,
- int textlines,
- int textwidth,
- double weightx, double weighty,
- int gridweight, int gridheight) {
-
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridweight;
- c.gridheight = gridheight;
-
- TextArea texta = new TextArea(textlines, textwidth);
- texta.setEditable(false);
- gridbag.setConstraints(texta, c);
- add(texta);
- return(texta);
- }
-
- public List make_list(
- String name,
- int numitems,
- boolean multipicks,
- double weightx, double weighty,
- int gridweight, int gridheight) {
-
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridweight;
- c.gridheight = gridheight;
-
- List list = new List(numitems, multipicks);
- gridbag.setConstraints(list, c);
- add(list);
- return(list);
- }
-
- public void make_panel(
- Object arg,
- int gridx, int gridy,
- double weightx, double weighty,
- int gridwidth, int gridheight){
- Panel panel = (Panel) arg;
- c.gridx = gridx;
- c.gridy = gridy;
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridwidth;
- c.gridheight = gridheight;
- gridbag.setConstraints(panel, c);
- add(panel);
- }
-
- public void make_canvas(
- Canvas canvas,
- int gridx, int gridy,
- double weightx, double weighty,
- int gridwidth, int gridheight){
- c.gridx = gridx;
- c.gridy = gridy;
- c.weightx = weightx;
- c.weighty = weighty;
- c.gridwidth = gridwidth;
- c.gridheight = gridheight;
- gridbag.setConstraints(canvas, c);
- add(canvas);
- }
- }
-
-