繁体   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