editweightaction.java

来自「Petri网分析工具PIPE is open-source」· Java 代码 · 共 45 行

JAVA
45
字号
package pipe.gui;import java.awt.Container;import java.awt.event.ActionEvent;import javax.swing.AbstractAction;import javax.swing.JOptionPane;import pipe.dataLayer.Arc;//import pipe.dataLayer.ArrowLabel;public class EditWeightAction extends AbstractAction{  private String label;  private Container contentPane;  private Arc myArc;  public EditWeightAction(Container contentPane, Arc a){    this.contentPane = contentPane;    myArc = a;  }  public void actionPerformed(ActionEvent e){    int currentWeighting = myArc.getWeight();    String input = JOptionPane.showInputDialog("Weighting:", String.valueOf(currentWeighting));    try {      int newWeighting = Integer.parseInt(input);      if(newWeighting < 1)        JOptionPane.showMessageDialog(contentPane, "Weighting cannot be less than 1.  Please re-enter");      else        myArc.setWeight(newWeighting);    } catch(Exception exc){      if(input!=null)        JOptionPane.showMessageDialog(contentPane, "Please enter a number.", "Invalid entry", JOptionPane.ERROR_MESSAGE);      System.err.println(exc.toString());    }  }}

⌨️ 快捷键说明

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