Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding JPopupMenu

 
johny sill
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two Jlabels in JPanel.

one label has set to icon, other one is empty label.

When i click setIcon label i want to display one menu like this Registration
Allocation
ChangeStatus

when i click empty label i want to display same menu but i want hide some data like Registration
Allocation

how to do this,

Help me,

Thans in advance
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to perform an action when you click on your two labels, right? In that case it might be better to make them buttons instead (use JButton instead of JLabel).

Assuming your Registration, Allocation, and ChangeStatus are text fields, try something like this:

Create your three textfields.
Add them to a JPanel
Use the setVisible method to make them invisible at first.
Add an ActionListener to each of your buttons
The Action Listener for the first button will make all three text fields visible (using setVisible)
The Action Listener for the other button will only make the Registration field visible.
 
You showed up just in time for the waffles! And this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!