Here you can find the source of getButtonNumber(JButton btn)
Parameter | Description |
---|---|
btn | a parameter |
public static int getButtonNumber(JButton btn)
//package com.java2s; //License from project: Apache License import javax.swing.JButton; public class Main { /**//from w w w .j ava 2 s .co m * Takes number from button name. * @param btn * @return */ public static int getButtonNumber(JButton btn) { int value = -1; String svalue = btn.getText(); try { value = Integer.parseInt(svalue); } catch (NumberFormatException nfe) { } return value; } }