View Javadoc
1   /*
2    * Trip Tracker, a real-time position tracking system for the Internet.
3    * Copyright (C) 2006  Team Trip Tracker
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or (at your
8    * option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   * General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License along
16   * with this program; if not, write to the Free Software Foundation, Inc.,
17   * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18   */
19  
20  package triptracker.client.ui;
21  
22  import java.awt.event.ActionEvent;
23  
24  import javax.swing.AbstractAction;
25  
26  /***
27   * This action class provides a simple way to do an unconditional change to
28   * another form. This is easily done as part of a button action listener or any
29   * other action listener. 
30   */
31  @SuppressWarnings("serial")
32  public class ChangeFormAction extends AbstractAction {
33  	private final FormManager manager;
34  	private final Form form;
35  	
36  	/***
37  	 * Creates a change form action with <code>manager</code> as form manager
38  	 * and form as the form to be shown when the action event is triggered.
39  	 * 
40  	 * @param manager form manager 
41  	 * @param form form to be shown on action event
42  	 */
43  	public ChangeFormAction(FormManager manager, Form form) {
44  		this.manager = manager;
45  		this.form = form;
46  	}
47  
48  	/*** {@inheritDoc} */
49  	public void actionPerformed(ActionEvent e) {
50  		manager.showForm(form);
51  	}
52  
53  }