1 package org.enhydra.kelp.ant.deployer; 2 3 import org.enhydra.tool.common.ButtonPanel; 4 import javax.swing.*; 5 import java.awt.*; 6 import java.awt.event.*; 7 8 16 17 public class AntDeployButtonPanel extends ButtonPanel { 18 JButton jButtonDeploy = new JButton(); 19 JButton jButtonAbout = new JButton(); 20 JButton jButtonHelp = new JButton(); 21 JButton jButtonClose = new JButton(); 22 JButton jButtonCancel = new JButton(); 23 24 public AntDeployButtonPanel() { 25 try { 26 jbInit(); 27 pmInit(); 28 } 29 catch(Exception e) { 30 e.printStackTrace(); 31 } 32 } 33 private void jbInit() throws Exception { 34 jButtonDeploy.setText("Deploy"); 35 jButtonAbout.setText("About"); 36 jButtonHelp.setText("Help"); 37 jButtonClose.setText("Close"); 38 jButtonCancel.setText("Cancel"); 39 this.add(jButtonAbout, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 40 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 10, 0), 0, 0)); 41 this.add(jButtonClose, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 42 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 6), 0, 0)); 43 this.add(jButtonDeploy, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 44 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 6), 0, 0)); 45 this.add(jButtonCancel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 46 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 26), 0, 0)); 47 this.add(jButtonHelp, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 48 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 54, 10, 0), 0, 0)); 49 } 50 51 private void pmInit(){ 52 LocalButtonListener buttonListener = new LocalButtonListener(); 53 54 jButtonDeploy.setText(ButtonPanel.COMMAND_DEPLOY); 55 jButtonDeploy.setActionCommand(ButtonPanel.COMMAND_DEPLOY); 56 jButtonDeploy.addActionListener(buttonListener); 57 58 jButtonAbout.setText(ButtonPanel.COMMAND_ABOUT); 59 jButtonAbout.setActionCommand(ButtonPanel.COMMAND_ABOUT); 60 jButtonAbout.addActionListener(buttonListener); 61 62 jButtonHelp.setText(ButtonPanel.COMMAND_HELP); 63 jButtonHelp.setActionCommand(ButtonPanel.COMMAND_HELP); 64 jButtonHelp.addActionListener(buttonListener); 65 66 jButtonClose.setText(ButtonPanel.COMMAND_CLOSE); 67 jButtonClose.setActionCommand(ButtonPanel.COMMAND_CLOSE); 68 jButtonClose.addActionListener(buttonListener); 69 70 jButtonCancel.setText(ButtonPanel.COMMAND_CANCEL); 71 jButtonCancel.setActionCommand(ButtonPanel.COMMAND_CANCEL); 72 jButtonCancel.addActionListener(buttonListener); 73 } 74 75 private class LocalButtonListener implements ActionListener { 76 77 84 public void actionPerformed(ActionEvent e) { 85 Object source = null; 86 ActionEvent event = null; 87 88 source = e.getSource(); 89 if (source == jButtonDeploy) { 90 event = new ActionEvent(jButtonDeploy, ButtonPanel.DEPLOY, 91 jButtonDeploy.getActionCommand()); 92 } else if (source == jButtonClose) { 93 event = new ActionEvent(jButtonClose, ButtonPanel.CLOSE, 94 jButtonClose.getActionCommand()); 95 } else if (source == jButtonHelp) { 96 event = new ActionEvent(jButtonHelp, ButtonPanel.HELP, 97 jButtonHelp.getActionCommand()); 98 } else if (source == jButtonAbout) { 99 event = new ActionEvent(jButtonAbout, ButtonPanel.ABOUT, 100 jButtonAbout.getActionCommand()); 101 } else if (source == jButtonCancel) { 102 event = new ActionEvent(jButtonCancel, ButtonPanel.CANCEL, 103 jButtonCancel.getActionCommand()); 104 } 105 if (event != null) { 106 notifyActionListeners(event); 107 } 108 } 109 110 } 111 112 } | Popular Tags |