⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edittokenaction.java

📁 Petri网分析工具PIPE is open-source
💻 JAVA
字号:
package pipe.gui;import java.awt.Container;import java.awt.event.ActionEvent;import javax.swing.AbstractAction;import javax.swing.JOptionPane;import pipe.dataLayer.Place;/** * Action object that can be used to effect adding/removing tokens from a place */public class EditTokenAction extends AbstractAction {  private String label;  private Container contentPane;  private Place selected;  public EditTokenAction(Container contentPane, Place place) {    this.contentPane = contentPane;    selected = place;  }  /** Prompts the user for the number of tokens they want the place to have */  public void actionPerformed(ActionEvent e) {    int currentMarking = selected.getCurrentMarking();    String input = JOptionPane.showInputDialog("Number of tokens:", String.valueOf(currentMarking));    try {      int newMarking = Integer.parseInt(input);      if (newMarking < 0)        JOptionPane.showMessageDialog(contentPane,"Please enter a positive number.");      else        selected.setCurrentMarking(newMarking);    } catch (Exception exc) {      if (input != null)        JOptionPane.showMessageDialog(contentPane,"Please enter a number.","Invalid entry",JOptionPane.ERROR_MESSAGE);      System.err.println(exc.toString());    }    selected.repaint();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -