001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.dods;
024:
025: // Standard imports
026: import java.awt.*;
027: import javax.swing.*;
028: import java.beans.*;
029:
030: //
031: public class InstructPanel extends JPanel {
032: private GridBagLayout layoutMain = null;
033: private JPanel panelHelp = null;
034: private JPanel panelOptions = null;
035: private GridBagLayout layoutHelp = null;
036: private JLabel labelTitle = null;
037: private BorderLayout layoutOptions = null;
038: private JTextArea textInstruct = null;
039:
040: public InstructPanel() {
041: try {
042: jbInit();
043: pmInit();
044: } catch (Exception ex) {
045: ex.printStackTrace();
046: }
047: }
048:
049: //
050: protected String getInstruction() {
051: return textInstruct.getText();
052: }
053:
054: protected void setInstructions(String text) {
055: textInstruct.setText(text);
056: }
057:
058: protected void setTitle(String text) {
059: labelTitle.setText(text);
060: }
061:
062: protected String getTitle() {
063: return labelTitle.getText();
064: }
065:
066: protected void addInstuctor(Instructor i) {
067: if (i instanceof JPanel) {
068: panelOptions.removeAll();
069: panelOptions.add((JPanel) i, BorderLayout.CENTER);
070: setInstructions(i.getInstructions());
071: setTitle(i.getTitle());
072: } else {
073: throw new RuntimeException("Instructor not a JPanel "
074: + i.getTitle());
075: }
076: }
077:
078: //
079: private void pmInit() {
080: Font font = labelTitle.getFont();
081:
082: font = new Font(font.getName(), Font.BOLD, font.getSize());
083: labelTitle.setFont(font);
084: font = new Font(font.getName(), 0, font.getSize());
085: textInstruct.setFont(font);
086: textInstruct.setBackground(labelTitle.getBackground());
087: }
088:
089: private void jbInit() throws Exception {
090: labelTitle = (JLabel) Beans.instantiate(getClass()
091: .getClassLoader(), JLabel.class.getName());
092: panelHelp = (JPanel) Beans.instantiate(getClass()
093: .getClassLoader(), JPanel.class.getName());
094: panelOptions = (JPanel) Beans.instantiate(getClass()
095: .getClassLoader(), JPanel.class.getName());
096: layoutMain = (GridBagLayout) Beans.instantiate(getClass()
097: .getClassLoader(), GridBagLayout.class.getName());
098: layoutHelp = (GridBagLayout) Beans.instantiate(getClass()
099: .getClassLoader(), GridBagLayout.class.getName());
100: layoutOptions = (BorderLayout) Beans.instantiate(getClass()
101: .getClassLoader(), BorderLayout.class.getName());
102: textInstruct = (JTextArea) Beans.instantiate(getClass()
103: .getClassLoader(), JTextArea.class.getName());
104: labelTitle.setText("TITLE");
105: panelHelp.setLayout(layoutHelp);
106: textInstruct.setWrapStyleWord(true);
107: textInstruct.setLineWrap(true);
108: textInstruct.setEnabled(false);
109: textInstruct.setText("INSTRUCTIONS");
110: textInstruct.setDisabledTextColor(UIManager
111: .getColor("textText"));
112: textInstruct.setBackground(UIManager.getColor("text"));
113: textInstruct.setEditable(false);
114: panelHelp.add(labelTitle, new GridBagConstraints(0, 0, 1, 1,
115: 0.1, 0.0, GridBagConstraints.WEST,
116: GridBagConstraints.HORIZONTAL, new Insets(3, 5, 1, 5),
117: 0, 0));
118: panelHelp.add(textInstruct, new GridBagConstraints(0, 1, 1, 1,
119: 0.1, 0.0, GridBagConstraints.CENTER,
120: GridBagConstraints.HORIZONTAL, new Insets(1, 5, 2, 5),
121: 0, 0));
122: panelOptions.setLayout(layoutOptions);
123: this .setLayout(layoutMain);
124: this .add(panelHelp, new GridBagConstraints(0, 0, 1, 1, 0.1,
125: 0.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH,
126: new Insets(5, 5, 5, 5), 0, 0));
127: this .add(panelOptions, new GridBagConstraints(0, 3, 1, 1, 0.1,
128: 0.9, GridBagConstraints.SOUTH, GridBagConstraints.BOTH,
129: new Insets(2, 5, 2, 5), 0, 0));
130: }
131:
132: }
|