简体   繁体   English

数组到JLabel

[英]Array to JLabel

I have two Packages with java Class 我有两个Java类包

  • PKStrings PK字符串
  • PkJforms 密码表

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

    public int intOption;
}

I have JFrame with menu 我有菜单的JFrame

  • A click go jframe A, 点击进入jframe A,

    B click go jframe B, B点击进入jframe B,

    C click go jframe C, C单击进入jframe C,

    D click go jframe D D单击转到jframe D

And other frame in same package JFram01 , contains JLabel . 和同一包JFram01其他框架包含JLabel

How to recognize if you click on "A" and show that position label? 如何识别是否单击“ 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
        }

From what i understand u can use a public variable in your package and store value in it using the on click event on A, B, C ..... 据我了解,您可以在包中使用公共变量,并使用A,B,C ....上的点击事件在其中存储值。

then access that info from the jfaram you want 然后从您想要的jfaram访问该信息

eg 例如

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