为什么这个java键绑定不起作用?

时间:2017-01-23 11:57:19

标签: java swing jframe key-bindings

我有一个模拟华氏转换器的简单摄氏温度的JFrame。 我正在尝试做的是每当按下ENTER键时调用“转换”按钮动作。

我尝试过定义默认按钮(但不起作用)。

我的代码现在看起来像这样:

with
Dynamic Set OrderedSet as
Order(
    NonEmptyCrossJoin(
      [Dim Product].[Subcategory Name].[Subcategory Name].Members,
      [Dim Product].[Category Name].[Category Name].Members,
      [Measures].[Order Quantity],
       2
    ),
    [Measures].[Order Quantity],
    BDESC
)

Dynamic Set DenseOrderedSet as
Order(
    NonEmpty(
       OrderedSet,
       [Measures].[RankFirstMatch]
    ),
    [Measures].[Order Quantity],
    BDESC
)

Member [Measures].[Rank] as
Rank(
  ([Dim Product].[Subcategory Name].Currentmember,[Dim Product].[Category Name].CurrentMember),
  OrderedSet
)

Member [Measures].[RankFirstMatch] as
IIF(
    [Measures].[Order Quantity] 
    =
    (
        OrderedSet.Item([Measures].[Rank] -2),
        [Measures].[Order Quantity]
    ),
    NULL,
    [Measures].[Rank]
)

Member [Measures].[RankDenseSet] as
Rank(
  ([Dim Product].[Subcategory Name].Currentmember,[Dim Product].[Category Name].CurrentMember),
  DenseOrderedSet
)


Member [Measures].[DenseRank] as
IIF(
    [Measures].[RankDenseSet] = 0,
    (OrderedSet.Item([Measures].[Rank] -2),[Measures].[DenseRank]),
    [Measures].[RankDenseSet]
)


select {[Measures].[Order Quantity],[Measures].[Rank],[Measures].[RankFirstMatch],[Measures].[RankDenseSet],[Measures].[DenseRank]} on 0,
non empty OrderedSet on 1
from [Adventure Works DW2016CTP3]

1 个答案:

答案 0 :(得分:0)

不需要任何花哨的东西,只需将其添加到您的edittext设置中即可。

edittext.addActionListener((ae)-> button_convertActionPerformed(null));