
jadex.bdi.examples.alarmclock.BeepPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.examples.alarmclock;
import jadex.bdi.runtime.Plan;
import jadex.commons.SUtil;
import jadex.commons.gui.GuiCreator;
import java.awt.Component;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
/**
* Play a beep.
*/
public class BeepPlan extends Plan
{
//-------- methods --------
/**
* The body method is called on the
* instatiated plan instance from the scheduler.
*/
public void body()
{
Alarm alarm = (Alarm)getParameter("alarm").getValue();
final Component parent = ((GuiCreator)getBeliefbase().getBelief("gui").getFact()).getGui(); // Hack!
final String message = alarm.getMessage()!=null ? SUtil.wrapText(alarm.getMessage()) : null;
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(parent, message, "Alarm is due", JOptionPane.INFORMATION_MESSAGE);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy