Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Specific sequence for multiple ActionListener(s) on one component

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Specific sequence for multiple ActionListener(s) on one component

    Hello,

    I'm attempting to integrate someone else's (Dave Gilbert) date-picker GUI class into an MVC-based application I'm writing. Dave's class extends JPanel and implements ActionListener. The date picker has several JButtons, each registering the date pcker class as its actionListener.

    I'm embedding his class into a view of my own, and attempting to link the ActionPerformed method from the date picker with my own controller which carries out functionality specific to my application.

    I've created an accessor method so that I can get to the buttons, then added an actionListener (which is my controller) to each button.

    This sorta works, but I find that my controller intercepts the event first before the date picker does. I would like to have the date picker class do it's ActionPerformed method first, then my controller do it's bit.

    package com.ma.dev;
     
    /* 
     * JCommon : a free general purpose class library for the Java(tm) platform
     * 
     *
     * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
     * 
     * Project Info:  http://www.jfree.org/jcommon/index.html
     *
     * This library is free software; you can redistribute it and/or modify it 
     * under the terms of the GNU Lesser General Public License as published by 
     * the Free Software Foundation; either version 2.1 of the License, or 
     * (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful, but 
     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
     * License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
     * USA.  
     *
     * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
     * in the United States and other countries.]
     * 
     * ---------------------
     * DateChooserPanel.java
     * ---------------------
     * (C) Copyright 2000-2004, by Object Refinery Limited.
     *
     * Original Author:  David Gilbert (for Object Refinery Limited);
     * Contributor(s):   -;
     *
     * $Id: DateChooserPanel.java,v 1.11 2007/11/02 17:50:36 taqua Exp $
     *
     * Changes (from 26-Oct-2001)
     * --------------------------
     * 26-Oct-2001 : Changed package to com.jrefinery.ui.* (DG);
     * 08-Dec-2001 : Dropped the getMonths() method (DG);
     * 13-Oct-2002 : Fixed errors reported by Checkstyle (DG);
     * 02-Nov-2005 : Fixed a bug where the current day-of-the-month is past
     *               the end of the newly selected month when the month or year
     *               combo boxes are changed - see bug id 1344319 (DG);
     *
     */
     
     
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.DateFormatSymbols;
    import java.util.Calendar;
    import java.util.Date;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingConstants;
    import javax.swing.UIManager;
     
    /**
     * A panel that allows the user to select a date.
     *
     * @author David Gilbert
     */
    public class DateChooserPanel extends JPanel implements ActionListener {
     
        /**
    	 * 
    	 */
    	private static final long serialVersionUID = -5138288194915618194L;
     
    	/**
         * The date selected in the panel.
         */
        private Calendar chosenDate;
     
        /**
         * The color for the selected date.
         */
        private Color chosenDateButtonColor;
     
        /**
         * The color for dates in the current month.
         */
        private Color chosenMonthButtonColor;
     
        /**
         * The color for dates that are visible, but not in the current month.
         */
        private Color chosenOtherButtonColor;
     
        /**
         * The first day-of-the-week.
         */
        private int firstDayOfWeek;
     
        /**
         * The range used for selecting years.
         */
        private int yearSelectionRange = 20;
     
        /**
         * The font used to display the date.
         */
        private Font dateFont = new Font("SansSerif", Font.PLAIN, 10);
     
        /**
         * A combo for selecting the month.
         */
        private JComboBox monthSelector;
     
        /**
         * A combo for selecting the year.
         */
        private JComboBox yearSelector;
     
        /**
         * A button for selecting today's date.
         */
        private JButton todayButton;
     
        /**
         * An array of buttons used to display the days-of-the-month.
         */
        private JButton[] buttons;
     
        /**
         * A flag that indicates whether or not we are currently refreshing the 
         * buttons.
         */
        private boolean refreshing = false;
     
        /**
         * The ordered set of all seven days of a week,
         * beginning with the 'firstDayOfWeek'.
         */
        private int[] WEEK_DAYS;
     
        /**
         * Constructs a new date chooser panel, using today's date as the initial 
         * selection.
         */
        public DateChooserPanel() {
            this(Calendar.getInstance(), false);
        }
     
        /**
         * Constructs a new date chooser panel.
         *
         * @param calendar     the calendar controlling the date.
         * @param controlPanel a flag that indicates whether or not the 'today' 
         *                     button should appear on the panel.
         */
        public DateChooserPanel(final Calendar calendar, 
                                final boolean controlPanel) {
     
            super(new BorderLayout());
     
            this.chosenDateButtonColor = UIManager.getColor("textHighlight");
            this.chosenMonthButtonColor = UIManager.getColor("control");
            this.chosenOtherButtonColor = UIManager.getColor("controlShadow");
     
            // the default date is today...
            this.chosenDate = calendar;
            this.firstDayOfWeek = calendar.getFirstDayOfWeek();
            this.WEEK_DAYS = new int[7];
            for (int i = 0; i < 7; i++) {
                this.WEEK_DAYS[i] = ((this.firstDayOfWeek + i - 1) % 7) + 1;
            }
     
            add(constructSelectionPanel(), BorderLayout.NORTH);
            add(getCalendarPanel(), BorderLayout.CENTER);
            if (controlPanel) {
                add(constructControlPanel(), BorderLayout.SOUTH);
            }
            setDate(calendar.getTime());
        }
     
        /**
         * Sets the date chosen in the panel.
         *
         * @param theDate the new date.
         */
        public void setDate(final Date theDate) {
     
            this.chosenDate.setTime(theDate);
            this.monthSelector.setSelectedIndex(this.chosenDate.get(
                    Calendar.MONTH));
            refreshYearSelector();
            refreshButtons();
     
        }
     
        /**
         * Returns the date selected in the panel.
         *
         * @return the selected date.
         */
        public Date getDate() {
            return this.chosenDate.getTime();
        }
     
        /**
         * Handles action-events from the date panel.
         *
         * @param e information about the event that occurred.
         */
        public void actionPerformed(final ActionEvent e) {
     
            if (e.getActionCommand().equals("monthSelectionChanged")) {
                final JComboBox c = (JComboBox) e.getSource();
     
                // In most cases, changing the month will not change the selected
                // day.  But if the selected day is 29, 30 or 31 and the newly
                // selected month doesn't have that many days, we revert to the 
                // last day of the newly selected month...
                int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH);
                this.chosenDate.set(Calendar.DAY_OF_MONTH, 1);
                this.chosenDate.set(Calendar.MONTH, c.getSelectedIndex());
                int maxDayOfMonth = this.chosenDate.getActualMaximum(
                        Calendar.DAY_OF_MONTH);
                this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
                        maxDayOfMonth));
                refreshButtons();
     
            }
            else if (e.getActionCommand().equals("yearSelectionChanged")) {
                if (!this.refreshing) {
                    final JComboBox c = (JComboBox) e.getSource();
                    final Integer y = (Integer) c.getSelectedItem();
     
                    // in most cases, changing the year will not change the 
                    // selected day.  But if the selected day is Feb 29, and the
                    // newly selected year is not a leap year, we revert to 
                    // Feb 28...
                    int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH);
                    this.chosenDate.set(Calendar.DAY_OF_MONTH, 1);
                    this.chosenDate.set(Calendar.YEAR, y.intValue());
                    int maxDayOfMonth = this.chosenDate.getActualMaximum(
                        Calendar.DAY_OF_MONTH);
                    this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, 
                        maxDayOfMonth));
                    refreshYearSelector();
                    refreshButtons();
                }
            }
            else if (e.getActionCommand().equals("todayButtonClicked")) {
                setDate(new Date());
            }
            else if (e.getActionCommand().equals("dateButtonClicked")) {
                final JButton b = (JButton) e.getSource();
                final int i = Integer.parseInt(b.getName());
                final Calendar cal = getFirstVisibleDate();
                cal.add(Calendar.DATE, i);
                setDate(cal.getTime());
            }
        }
     
        /**
         * Returns a panel of buttons, each button representing a day in the month.
         * This is a sub-component of the DatePanel.
         *
         * @return the panel.
         */
        private JPanel getCalendarPanel() {
     
            final JPanel p = new JPanel(new GridLayout(7, 7));
            final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
            final String[] weekDays = dateFormatSymbols.getShortWeekdays();
     
            for (int i = 0; i < this.WEEK_DAYS.length; i++) {
                p.add(new JLabel(weekDays[this.WEEK_DAYS[i]], 
                        SwingConstants.CENTER));
            }
     
            this.buttons = new JButton[42];
            for (int i = 0; i < 42; i++) {
                final JButton b = new JButton("");
                b.setMargin(new Insets(1, 1, 1, 1));
                b.setName(Integer.toString(i));
                b.setFont(this.dateFont);
                b.setFocusPainted(false);
                b.setActionCommand("dateButtonClicked");
                b.addActionListener(this);
                this.buttons[i] = b;
                p.add(b);
            }
            return p;
     
        }
     
        public JButton[] getButtons() {
        	return buttons;
        }
        /**
         * Returns the button color according to the specified date.
         *
         * @param theDate the date.
         * @return the color.
         */
        private Color getButtonColor(final Calendar theDate) {
            if (equalDates(theDate, this.chosenDate)) {
                return this.chosenDateButtonColor;
            }
            else if (theDate.get(Calendar.MONTH) == this.chosenDate.get(
                    Calendar.MONTH)) {
                return this.chosenMonthButtonColor;
            }
            else {
                return this.chosenOtherButtonColor;
            }
        }
     
        /**
         * Returns true if the two dates are equal (time of day is ignored).
         *
         * @param c1 the first date.
         * @param c2 the second date.
         * @return boolean.
         */
        private boolean equalDates(final Calendar c1, final Calendar c2) {
            if ((c1.get(Calendar.DATE) == c2.get(Calendar.DATE))
                && (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH))
                && (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR))) {
                return true;
            }
            else {
                return false;
            }
        }
     
        /**
         * Returns the first date that is visible in the grid.  This should always 
         * be in the month preceding the month of the selected date.
         *
         * @return the date.
         */
        private Calendar getFirstVisibleDate() {
            final Calendar c = Calendar.getInstance();
            c.set(this.chosenDate.get(Calendar.YEAR), this.chosenDate.get(
                    Calendar.MONTH), 1);
            c.add(Calendar.DATE, -1);
            while (c.get(Calendar.DAY_OF_WEEK) != getFirstDayOfWeek()) {
                c.add(Calendar.DATE, -1);
            }
            return c;
        }
     
        /**
         * Returns the first day of the week (controls the labels in the date 
         * panel).
         *
         * @return the first day of the week.
         */
        private int getFirstDayOfWeek() {
            return this.firstDayOfWeek;
        }
     
        /**
         * Update the button labels and colors to reflect date selection.
         */
        private void refreshButtons() {
            final Calendar c = getFirstVisibleDate();
            for (int i = 0; i < 42; i++) {
                final JButton b = this.buttons[i];
                b.setText(Integer.toString(c.get(Calendar.DATE)));
                b.setBackground(getButtonColor(c));
                c.add(Calendar.DATE, 1);
            }
        }
     
        /**
         * Changes the contents of the year selection JComboBox to reflect the 
         * chosen date and the year range.
         */
        private void refreshYearSelector() {
            if (!this.refreshing) {
                this.refreshing = true;
                this.yearSelector.removeAllItems();
                final Integer[] years = getYears(this.chosenDate.get(
                        Calendar.YEAR));
                for (int i = 0; i < years.length; i++) {
                    this.yearSelector.addItem(years[i]);
                }
                this.yearSelector.setSelectedItem(new Integer(this.chosenDate.get(
                        Calendar.YEAR)));
                this.refreshing = false;
            }
        }
     
        /**
         * Returns a vector of years preceding and following the specified year.  
         * The number of years preceding and following is determined by the 
         * yearSelectionRange attribute.
         *
         * @param chosenYear the selected year.
         * @return a vector of years.
         */
        private Integer[] getYears(final int chosenYear) {
            final int size = this.yearSelectionRange * 2 + 1;
            final int start = chosenYear - this.yearSelectionRange;
     
            final Integer[] years = new Integer[size];
            for (int i = 0; i < size; i++) {
                years[i] = new Integer(i + start);
            }
            return years;
        }
     
        /**
         * Constructs a panel containing two JComboBoxes (for the month and year) 
         * and a button (to reset the date to TODAY).
         *
         * @return the panel.
         */
        private JPanel constructSelectionPanel() {
            final JPanel p = new JPanel();
     
            final int minMonth = this.chosenDate.getMinimum(Calendar.MONTH);
            final int maxMonth = this.chosenDate.getMaximum(Calendar.MONTH);
            final String[] months = new String[maxMonth - minMonth + 1];
            for(int i=0;i<months.length;i++){
              months[i] = ""+i;
            } 
     
     
            this.monthSelector = new JComboBox(months);
            this.monthSelector.addActionListener(this);
            this.monthSelector.setActionCommand("monthSelectionChanged");
            p.add(this.monthSelector);
     
            this.yearSelector = new JComboBox(getYears(0));
            this.yearSelector.addActionListener(this);
            this.yearSelector.setActionCommand("yearSelectionChanged");
            p.add(this.yearSelector);
     
            return p;
        }
     
        /**
         * Returns a panel that appears at the bottom of the calendar panel - 
         * contains a button for selecting today's date.
         *
         * @return the panel.
         */
        private JPanel constructControlPanel() {
     
            final JPanel p = new JPanel();
            p.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5));
            this.todayButton = new JButton("Today");
            this.todayButton.addActionListener(this);
            this.todayButton.setActionCommand("todayButtonClicked");
            p.add(this.todayButton);
            return p;
     
        }
     
        /**
         * Returns the color for the currently selected date.
         *
         * @return a color.
         */
        public Color getChosenDateButtonColor() {
            return this.chosenDateButtonColor;
        }
     
        /**
         * Redefines the color for the currently selected date.
         *
         * @param chosenDateButtonColor the new color
         */
        public void setChosenDateButtonColor(final Color chosenDateButtonColor) {
            if (chosenDateButtonColor == null) {
                throw new NullPointerException("UIColor must not be null.");
            }
            final Color oldValue = this.chosenDateButtonColor;
            this.chosenDateButtonColor = chosenDateButtonColor;
            refreshButtons();
            firePropertyChange("chosenDateButtonColor", oldValue, 
                    chosenDateButtonColor);
        }
     
        /**
         * Returns the color for the buttons representing the current month.
         *
         * @return the color for the current month.
         */
        public Color getChosenMonthButtonColor() {
            return this.chosenMonthButtonColor;
        }
     
        /**
         * Defines the color for the buttons representing the current month.
         *
         * @param chosenMonthButtonColor the color for the current month.
         */
        public void setChosenMonthButtonColor(final Color chosenMonthButtonColor) {
            if (chosenMonthButtonColor == null) {
                throw new NullPointerException("UIColor must not be null.");
            }
            final Color oldValue = this.chosenMonthButtonColor;
            this.chosenMonthButtonColor = chosenMonthButtonColor;
            refreshButtons();
            firePropertyChange("chosenMonthButtonColor", oldValue, 
                    chosenMonthButtonColor);
        }
     
        /**
         * Returns the color for the buttons representing the other months.
         *
         * @return a color.
         */
        public Color getChosenOtherButtonColor() {
            return this.chosenOtherButtonColor;
        }
     
        /**
         * Redefines the color for the buttons representing the other months.
         *
         * @param chosenOtherButtonColor a color.
         */
        public void setChosenOtherButtonColor(final Color chosenOtherButtonColor) {
            if (chosenOtherButtonColor == null) {
                throw new NullPointerException("UIColor must not be null.");
            }
            final Color oldValue = this.chosenOtherButtonColor;
            this.chosenOtherButtonColor = chosenOtherButtonColor;
            refreshButtons();
            firePropertyChange("chosenOtherButtonColor", oldValue, 
                    chosenOtherButtonColor);
        }
     
        /**
         * Returns the range of years available for selection (defaults to 20).
         * 
         * @return The range.
         */
        public int getYearSelectionRange() {
            return this.yearSelectionRange;
        }
     
        /**
         * Sets the range of years available for selection.
         * 
         * @param yearSelectionRange  the range.
         */
        public void setYearSelectionRange(final int yearSelectionRange) {
            final int oldYearSelectionRange = this.yearSelectionRange;
            this.yearSelectionRange = yearSelectionRange;
            refreshYearSelector();
            firePropertyChange("yearSelectionRange", oldYearSelectionRange, 
                    yearSelectionRange);
        }
    }

    My controller:
    package com.ma.dev.controller;
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.text.SimpleDateFormat;
     
    import javax.swing.JButton;
     
    import com.ma.dev.model.ProjectModel;
    import com.ma.dev.view.ProjectView;
     
    public class ProjectController implements ActionListener, ItemListener, KeyListener {
     
    	private ProjectModel model;
    	private ProjectView view;
     
    	public ProjectController(ProjectModel m, ProjectView v) {
    		setModel(m);
    		setView(v);
    		getView().addActionListener(this);
    		getView().getBtnCal().addActionListener(this);
    		JButton[] buttons=getView().getCalendar().getButtons();
    		for(int b=0;b<buttons.length;b++) {
    			buttons[b].addActionListener(this);
    		}
    		clearAllFields();
    	}
     
    	public void clearAllFields() {
    		getModel().setProjectID("");
    		getModel().setProjectTitle("");
    		getModel().setDeveloperName("");
    		getModel().setProjectManager("");
    		getModel().setTaskName("");
    		getModel().setStartDate("");
    		getModel().setNotes(new String());
    		SimpleDateFormat df=new SimpleDateFormat("MM/dd/yyyy");
    		String today=df.format(getView().getCalendar().getDate().getTime());
    		getModel().setToday(today);
    		getView().getStartDate().setText(today);
    	}
     
    	public void setAllFields() {
    		getView().getProjectID().setText(getModel().getProjectID());
    		getView().getProjectTitle().setText(getModel().getProjectTitle());
    		getView().getDeveloperName().setText(getModel().getDeveloperName());
    		getView().getNotes().setText(getModel().getNotes());
    		getView().getStartDate().setText(getModel().getStartDate());
    		getView().getTaskName().setText(getModel().getTaskName());
    		getView().getProjectManager().setText(getModel().getProjectManager());
    		getView().getStartDate().setText(getModel().getToday());
    	}
    	public void setModel(ProjectModel model) {
    		this.model = model;
    	}
     
    	public ProjectModel getModel() {
    		return model;
    	}
     
    	public void setView(ProjectView view) {
    		this.view = view;
    	}
     
    	public ProjectView getView() {
    		return view;
    	}
     
    	@Override
    	public void actionPerformed(ActionEvent event) {
    		// TODO Auto-generated method stub
    		String src=event.getActionCommand();
    		if(src.equals("SHOW_CALENDAR")) {
    			if(getView().getCalendar().isVisible()) {
    				getView().getCalendar().setVisible(false);
    			} else {
    				getView().getCalendar().setVisible(true);
    			}
    		}
    	}
     
    	@Override
    	public void itemStateChanged(ItemEvent e) {
    		// TODO Auto-generated method stub
    	}
     
    	@Override
    	public void keyPressed(KeyEvent e) {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public void keyReleased(KeyEvent e) {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public void keyTyped(KeyEvent e) {
    		// TODO Auto-generated method stub
     
    	}
     
    }

    I'm thinking that the way I'm going about this is not a "best practice", and that what I really need to do is to utilize a message queue or event queue of some sort.
    Last edited by Fender; October 19th, 2010 at 07:16 AM. Reason: additional thoughts


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,099
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Specific sequence for multiple ActionListener(s) on one component

    If you want a specific order, you may wish to create an ActionListener class which dispatches the event to other listeners in a particular order. You could do this through a Queue or LinkedList which contains the 'child' listeners. This would then be the only listener registered with the JButton. (Learn something new every day: I would have presumed the listeners fire in the order they are added: however a quick test shows the order is reversed. )

  3. The Following User Says Thank You to copeg For This Useful Post:

    Fender (October 19th, 2010)

  4. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: Specific sequence for multiple ActionListener(s) on one component

    That the listeners fire in the reverse of the order in which they were added is fairly well known, but it is not a documented behavior, just an implementation detail and as such should not be relied on. The same is true of all listeners in Swing (no idea about AWT).

    To enforce an order of your own, you need to first retrieve and retain a reference to the default ActionListener/s using getActionListeners(), then remove them using removeActionListener. Now add your own ActionListener which must iterate over the removed listeners calling each one's actionPerformed and finally perform your custom action. Note that depending on the complexity of interaction, you may still need to wrap the code for your custom action in a SwingUtilities#invokeLater.

    db

  5. The Following User Says Thank You to Darryl.Burke For This Useful Post:

    Fender (October 19th, 2010)

  6. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default [SOLVED] Re: Specific sequence for multiple ActionListener(s) on one component

    Thank you folks.
    The suggestions and additional info presented here were very useful.

    I ended up doing pretty much what was suggested, which works fine. I may not have implemented it very elegantly, but it does work, and for now that's all I care about. Elegant can happen later.


    In my controller's constructor:
    	public ProjectController(ProjectModel m, ProjectView v) {
    		setModel(m);
    		setView(v);
    		getView().addActionListener(this);
    		getView().getBtnCal().addActionListener(this);
    		JButton[] buttons=getView().getCalendar().getButtons();
    		for(int b=0;b<buttons.length;b++) {
    			ActionListener[] al=buttons[b].getActionListeners();
    			for(int a=0;a<al.length;a++) {
    				ActionListener listener=al[a];
    				buttons[b].removeActionListener(listener);
    			}
    			buttons[b].addActionListener(this);
    		}
    		clearAllFields();
    	}

    Then in the my controller's actionPerformed method, I can invoke the date picker's ActionPerformed method, and follow it up with my controller's duties:
    	public void actionPerformed(ActionEvent event) {
    		// TODO Auto-generated method stub
    		String src=event.getActionCommand();
    		if(src.equals("SHOW_CALENDAR")) {
    			if(getView().getCalendar().isVisible()) {
    				getView().getCalendar().setVisible(false);
    			} else {
    				getView().getCalendar().setVisible(true);
    			}
    		}
    		if(src.equals("dateButtonClicked")) {
    			getView().getCalendar().actionPerformed(event);
                           // do controller-specific stuff here...
     
    		}
    	}

Similar Threads

  1. Returning the equilibrium index in a sequence of integers
    By thanasisk in forum Algorithms & Recursion
    Replies: 4
    Last Post: September 3rd, 2013, 02:20 PM
  2. [SOLVED] Specific Text Extraction from PDF Research paper documents
    By user101 in forum Threads
    Replies: 1
    Last Post: September 8th, 2010, 11:30 AM
  3. How to write to specific part of an html file using java
    By nasi in forum File I/O & Other I/O Streams
    Replies: 12
    Last Post: May 27th, 2010, 11:22 PM
  4. [SOLVED] Problem accessing specific data in an array and getting it to return properly
    By Universalsoldja in forum Collections and Generics
    Replies: 3
    Last Post: February 4th, 2010, 03:26 PM
  5. Need some general and specific advice.
    By Morevan in forum Loops & Control Statements
    Replies: 2
    Last Post: January 3rd, 2010, 10:31 PM