我正在研究Java框架,并希望允许用户编写一些代码并将其发送到我的框架,我的框架管理器将基于某些因素间歇性地运行它。我基本上希望做一些类似于Swing在点击按钮时使用的东西。我已经搜索过,并且没有找到任何方法来实现这个,所以我可以使用一些设计方法来实现这个目标吗?
Swing示例:
showDialogButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// display/center the jdialog when the button is pressed
JDialog d = new JDialog(frame, "Hello", true);
d.setLocationRelativeTo(frame);
d.setVisible(true);
}
});