001: package org.enhydra.kelp.ant.xmlc;
002:
003: import org.enhydra.tool.common.ButtonPanel;
004: import javax.swing.*;
005: import java.awt.*;
006: import java.awt.event.*;
007:
008: /**
009: * <p>Title: </p>
010: * <p>Description: </p>
011: * <p>Copyright: Copyright (c) 2003</p>
012: * <p>Company: </p>
013: * @author unascribed
014: * @version 1.0
015: */
016:
017: public class AntXMLCButtonPanel extends ButtonPanel {
018: JButton jButtonCompile = new JButton();
019: JButton jButtonAbout = new JButton();
020: JButton jButtonHelp = new JButton();
021: JButton jButtonClose = new JButton();
022: JButton jButtonCancel = new JButton();
023:
024: public AntXMLCButtonPanel() {
025: try {
026: jbInit();
027: pmInit();
028: } catch (Exception e) {
029: e.printStackTrace();
030: }
031: }
032:
033: private void jbInit() throws Exception {
034: jButtonCompile.setText("Compile");
035: jButtonAbout.setText("About");
036: jButtonHelp.setText("Help");
037: jButtonClose.setText("Close");
038: jButtonCancel.setText("Cancel");
039: this
040: .add(jButtonAbout, new GridBagConstraints(4, 0, 1, 1,
041: 0.0, 0.0, GridBagConstraints.CENTER,
042: GridBagConstraints.NONE,
043: new Insets(0, 5, 10, 0), 0, 0));
044: this
045: .add(jButtonClose, new GridBagConstraints(1, 0, 1, 1,
046: 0.0, 0.0, GridBagConstraints.CENTER,
047: GridBagConstraints.NONE,
048: new Insets(0, 0, 10, 6), 0, 0));
049: this
050: .add(jButtonCompile, new GridBagConstraints(0, 0, 1, 1,
051: 0.0, 0.0, GridBagConstraints.CENTER,
052: GridBagConstraints.NONE,
053: new Insets(0, 0, 10, 6), 0, 0));
054: this .add(jButtonCancel,
055: new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
056: GridBagConstraints.CENTER,
057: GridBagConstraints.NONE, new Insets(0, 0, 10,
058: 26), 0, 0));
059: this .add(jButtonHelp,
060: new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
061: GridBagConstraints.CENTER,
062: GridBagConstraints.NONE, new Insets(0, 54, 10,
063: 0), 0, 0));
064: }
065:
066: private void pmInit() {
067: LocalButtonListener buttonListener = new LocalButtonListener();
068:
069: jButtonCompile.setText(ButtonPanel.COMMAND_COMPILE);
070: jButtonCompile.setActionCommand(ButtonPanel.COMMAND_COMPILE);
071: jButtonCompile.addActionListener(buttonListener);
072:
073: jButtonAbout.setText(ButtonPanel.COMMAND_ABOUT);
074: jButtonAbout.setActionCommand(ButtonPanel.COMMAND_ABOUT);
075: jButtonAbout.addActionListener(buttonListener);
076:
077: jButtonHelp.setText(ButtonPanel.COMMAND_HELP);
078: jButtonHelp.setActionCommand(ButtonPanel.COMMAND_HELP);
079: jButtonHelp.addActionListener(buttonListener);
080:
081: jButtonClose.setText(ButtonPanel.COMMAND_CLOSE);
082: jButtonClose.setActionCommand(ButtonPanel.COMMAND_CLOSE);
083: jButtonClose.addActionListener(buttonListener);
084:
085: jButtonCancel.setText(ButtonPanel.COMMAND_CANCEL);
086: jButtonCancel.setActionCommand(ButtonPanel.COMMAND_CANCEL);
087: jButtonCancel.addActionListener(buttonListener);
088: }
089:
090: private class LocalButtonListener implements ActionListener {
091:
092: /**
093: * ActionListener implementation.
094: *
095: * @param event
096: * Event that triggered this listener.
097: *
098: */
099: public void actionPerformed(ActionEvent e) {
100: Object source = null;
101: ActionEvent event = null;
102:
103: source = e.getSource();
104: if (source == jButtonCompile) {
105: event = new ActionEvent(jButtonCompile,
106: ButtonPanel.COMPILE, jButtonCompile
107: .getActionCommand());
108: } else if (source == jButtonClose) {
109: event = new ActionEvent(jButtonClose,
110: ButtonPanel.CLOSE, jButtonClose
111: .getActionCommand());
112: } else if (source == jButtonHelp) {
113: event = new ActionEvent(jButtonHelp, ButtonPanel.HELP,
114: jButtonHelp.getActionCommand());
115: } else if (source == jButtonAbout) {
116: event = new ActionEvent(jButtonAbout,
117: ButtonPanel.ABOUT, jButtonAbout
118: .getActionCommand());
119: } else if (source == jButtonCancel) {
120: event = new ActionEvent(jButtonCancel,
121: ButtonPanel.CANCEL, jButtonCancel
122: .getActionCommand());
123: }
124: if (event != null) {
125: notifyActionListeners(event);
126: }
127: }
128:
129: }
130:
131: }
|