Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:08:49+00:00 2026-06-16T03:08:49+00:00

The idea is to create a JPopupMenu that will show up right underneath the

  • 0

enter image description here

The idea is to create a JPopupMenu that will show up right underneath the exclamation mark when I LEFT CLICK on it.
I am not using the isPopupTrigger() method as I have created a separate MouseInputHandlerto implement my specific condition.
However the JPopupMenu does not show up.
Here is the code:

protected class LabelHandler extends MouseInputAdapter{


    @Override
    public void mouseClicked(MouseEvent e){
        JLabel cause = (JLabel) e.getSource();
        if(cause == saveLabel){
            try{
                desktop.open(f);
            }catch(IOException ex){
                ex.printStackTrace();
            }
        }else if(cause == downLabel){

            popup.show(ScreenRecorder.this, e.getX(),e.getY());
        }
    }

    @Override
    public void mouseEntered(MouseEvent e){
        JLabel cause = (JLabel) e.getSource();
        if(cause == saveLabel){
            saveLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }else if(cause == downLabel){
            downLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }
    }

    @Override
    public void mouseExited(MouseEvent e){
        JLabel cause = (JLabel) e.getSource();
        if(cause == saveLabel || cause == saveLabel){
            saveLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }else if(cause == downLabel){
            downLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    }
}

The label is named downLabel cause it was supposed to be an arrow pointing downwards but anyways, I put an exclamation there. Please tell me why the JPopupMenu does not show up. Yes, I set up the menu in another method.

EDIT:

Code for creating the JPopup:

public void setupJPopup(){
        encodingGroup.add(avi);
        encodingGroup.add(quicktime);

        popup.add(avi);
        popup.add(quicktime);
        popup.addSeparator();

        recordingAreaGroup.add(entireScreen);
        recordingAreaGroup.add(custom);

        popup.add(entireScreen);
        popup.add(custom);
        popup.addSeparator();

        cursorGroup.add(selectBlackCursor);
        cursorGroup.add(selectWhiteCursor);
        cursorGroup.add(selectNoCursor);

        selectCursor.add(selectBlackCursor);
        selectCursor.add(selectWhiteCursor);
        selectCursor.add(selectNoCursor);

        popup.add(selectCursor);
        popup.pack();
    }  

Variables involved in the above code are:

/* Creating the JPopupMenu containing the various menu items */
    JPopupMenu popup = new JPopupMenu();

    ButtonGroup encodingGroup = new ButtonGroup();
    ButtonGroup recordingAreaGroup = new ButtonGroup();
    ButtonGroup cursorGroup = new ButtonGroup();

    /* Handler for labels*/
    LabelHandler labelHandler = new LabelHandler();

    JRadioButtonMenuItem avi = new JRadioButtonMenuItem("AVI",true);
    JRadioButtonMenuItem quicktime = new JRadioButtonMenuItem("QuickTime",false);
    JRadioButtonMenuItem entireScreen = new JRadioButtonMenuItem("Entire Screen",true);
    JRadioButtonMenuItem custom = new JRadioButtonMenuItem("Custom...",false);
    JMenu selectCursor = new JMenu("Select a cursor");
    JRadioButtonMenuItem selectWhiteCursor = new JRadioButtonMenuItem("White Cursor",true);
    JRadioButtonMenuItem selectBlackCursor = new JRadioButtonMenuItem("Black Cursor",false);
    JRadioButtonMenuItem selectNoCursor = new JRadioButtonMenuItem("No Cursor",false);
/* Icons for the cursors */
    Icon blackCursor = (Icon) new ImageIcon("src/images/blackCursor.png");
    Icon whiteCursor = (Icon) new ImageIcon("src/images/whiteCursor.png");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:08:52+00:00Added an answer on June 16, 2026 at 3:08 am

    Can you Post the relevant code for popup.

    Or better a SSCCE.

    I canot reproduce your problem.


    You should use

    saveLabel.equals(cause)
    

    insread of

    cause == saveLabel
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if its the best idea to create a background job that
The idea: To create a countdown to show days or hours left until some
I recently had an idea to create my own String class to make using
My idea is to create a .jar file that contains Services managed by Spring,
Has anybody got an idea of how to create a .Contains(string) function using Linq
Let me just say right off the bat that i'm not a programmer. I'm
I had this idea: create a program that simulates the visual studio to help
Curious whether or not it is a bad idea to create Users with password
My problem is that I don't have an idea to create a list of
I have an idea to create scripting language which will make people to program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.