cho em hỏi thuộc tính tag trong C# giống với thuộc tính nào trong java ạ. em cảm ơn

monthui0002

New Member
3/4/20
2
0
1
Hanoi
Em định làm 1 cái Label khi nhấn vào thì thực hiện events trên các label trong cái label lớn đó. em để hết các label con vô 1 mảng(em dùng stack) rồi ép kiểu JLabel. Thấy C# họ hướng dẫn dùng nameLabel.Tag = Stack<t>() nhưng em ko biết java thì muốn làm sẽ đổi thành gì. em cảm ơn ạ
 

Joe

Thành viên VIP
21/1/13
2,889
1,291
113
If you learn an Object Oriented Programming Language (OOPL) like JAVA or C# you have firstly to study the APIs you want to work with. And that is the very first thing you have to do. Otherwise you get nowhere with your OOPL learning. So, what does JLable API say? It says:
JLabel is a Child of JComponent, grandchild of Container, grand-grandchild of Component and its ancestor is Object. So, JLabel inherits all methods that are provided by JLabel forefathers. If you don't find any "event" processing (or control) you have to work down to JComponent and it has the following "event-processing methods"
if they are NOT your desired methods you go down to Container and Container has these following methods:
Again you can finally find other "event-processing" methods in Component:
If none of the methods are "your" desired method you are OUT OF LUCK =))

Similar to C# Label is the JavaFX Label (or JFX Label). It's better to compare C# with JFX than with SWING.
Similar to JLabel all JFX Label "event-processing methods" are found in the Node API
 

quydtkt

Administrator
1/11/19
309
30
28
26
Bạn có thử thử với getUserData() và setUserData()