I have two Packages with java Class
public class classWork {
public String[] titleMenu={
"A","B","C","D"
};
public int intOption;
}
I have JFrame
with menu
A click go jframe A,
B click go jframe B,
C click go jframe C,
D click go jframe D
And other frame in same package JFram01
, contains JLabel
.
How to recognize if you click on "A" and show that position label?
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 .....
then access that info from the jfaram you want
eg
public String pos ="";
A onclick event(){
pos="A";
}
finally
if(pos.compareto("A")==0){
jlabel.settext("A");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.