簡體   English   中英

數組到JLabel

[英]Array to JLabel

我有兩個Java類包

  • PK字符串
  • 密碼表

public class classWork {
    public String[] titleMenu={
        "A","B","C","D"
    };

    public int intOption;
}

我有菜單的JFrame

  • 點擊進入jframe A,

    B點擊進入jframe B,

    C單擊進入jframe C,

    D單擊轉到jframe D

和同一包JFram01其他框架包含JLabel

如何識別是否單擊“ A”並顯示該位置標簽?

I dont understand your need. "A click A go jframe A" doesnot make sense.
if you want to go to another jFrame when clicking a label
Try this

    private void yourlabelMouseClicked(java.awt.event.MouseEvent evt) {
          //  either you can hide the current jFrame by setting 
            jFrame.setVisible(false);
            newjFrame.setVisible(True);
                    or
            make these jFrames in 2 different classes that make simple invocations
        }

據我了解,您可以在包中使用公共變量,並使用A,B,C ....上的點擊事件在其中存儲值。

然后從您想要的jfaram訪問該信息

例如

public String pos ="";

A onclick event(){
   pos="A";
}


finally

if(pos.compareto("A")==0){
   jlabel.settext("A");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM