onClick eclipse按钮

时间:2015-08-31 13:33:19

标签: java eclipse button onclick swt

我使用Eclipse Button

List<Button> aButtons = new ArrayList<Button>();
button = new Button(buttonsComposite, SWT.PUSH);
    button.setText(BTN_TEXT);
    aButtons.add(button);

我有listener

makeButtonsListen(new Listener() {

        @Override
        public void handleEvent(Event event) {
            handleButtonEvent(event);
        }
    });

private void makeButtonsListen(Listener listener) {
    for (Button button : aButtons) {
        button.addListener(SWT.Selection, listener);
    }
}

我的问题是我按下按钮后event.widget == button更改的价值。怎么做onClick?我希望当点击并保持值正在改变时。目前它发生在我按下按钮之后。

1 个答案:

答案 0 :(得分:2)

如果您想收听鼠标按下事件,请将听众添加到<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>KML Test</name> <StyleMap id="Tester-ICON"> <Pair> <key>normal</key> <styleUrl>#Tester-TEMPLATE</styleUrl> </Pair> <Pair> <key>highlight</key> <styleUrl>#Tester-TEMPLATE</styleUrl> </Pair> </StyleMap> <Style id="Tester-TEMPLATE"> <IconStyle> <scale>2</scale> <Icon> <href>http://maps.google.com/mapfiles/kml/paddle/ylw-stars.png</href> </Icon> </IconStyle> <LabelStyle> <color>ff0000ff</color> <scale>2</scale> </LabelStyle> <BalloonStyle> <text><![CDATA[ $[description] ]]> </text> </BalloonStyle> </Style> <Placemark id="Event 1"> <name>Event 1</name> <Snippet maxLines="0"></Snippet> <description> <![CDATA[ <style type="text/css"> .TDcell { color: Black; text-align: left; } .THeader { color: Black; font-weight: bold; white-space: nowrap; text-align: left; vertical-align: text-top; } </style> <p><b>Event ID:<b> 1</p> <p><b>Type of Event:<b> Formal Dinner</p> <hr> <table cellspacing="1" cellpadding="3" width="500"> <tr> <td class="THeader">Who:</td> <td class="TDcell">POTUS</td> </tr><tr> <td class="THeader">What:</td> <td class="TDcell">State of the Union Address</td> </tr><tr> <td class="THeader">When:</td> <td class="TDcell">Jan, 20th 2016</td> </tr><tr> <td class="THeader">Where:</td> <td class="TDcell">United States Capitol</td> </tr><tr> <td class="THeader">Why:</td> <td class="TDcell">Updates</td> </tr> </table>]]> </description> <styleUrl>#Tester-TEMPLATE</styleUrl> <Point> <coordinates>-77.009072,38.890131,0</coordinates> </Point> </Placemark> </Document> </kml> 而不是SWT.MouseDown

SWT.Selection