我如何从另一个方法访问变量?

时间:2015-04-24 13:46:11

标签: java variables

我想从this.s方法访问actionPerformed变量,并在addSignTag方法中使用它。 我怎么做?对不起重新发布!

 String s;
    public void actionPerformed(ActionEvent e)
    {
    int index = 0;

    int connectorCoorX = MyGraphics.prevX;
    int connectorCoorY = MyGraphics.prevY; 
    Way w = new Way();

    if(e.getActionCommand().equals("Check")){ 

        index = list.getSelectedIndex();
        System.out.println("Index selected" + index);
        this.s= (String) list.getSelectedValue();
        System.out.println("Value Selected " +this.s);
        createMap();
    }
}


public void addSignTag(Way w, String tagKey, String valueKey)

{   String key = Tag.removeWhiteSpaces(tagKey);
    String value = Tag.removeWhiteSpaces(valueKey);

    if (key.isEmpty() || value.isEmpty())
        return;


}

0 个答案:

没有答案