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

  • Home
  • SEARCH
  • 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 4253000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:53:19+00:00 2026-05-21T04:53:19+00:00

Hi all I have a JFrame and I’ve added a JButton to that JFrame.

  • 0

Hi all
I have a JFrame and I’ve added a JButton to that JFrame.
Also I’ve added an ActionListener to my JButton.
Now please convert this Pseudocode to Java :

public void actionPreformed(ActionEvent e){
    if (isShiftDown)
        print "Shift is Down.";
    else
        print "Shift is Up.";
}

Actually I want to know isShiftDown while my JButton pressed or not.

Thanks.

  • 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-05-21T04:53:20+00:00Added an answer on May 21, 2026 at 4:53 am

    replace isShiftDown by

    (e.getModifiers() & InputEvent.SHIFT_MASK) != 0

    (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0

    getModifiers() returns a bitmask of all modifiers pressed during an event (alt, ctrl, shift…) that you can bitwise-and to get the status of one of them. Pretty much what it says in the doc.

    Edit: As of Java 9 it is recommended to use InputEvent.SHIFT_DOWN_MASK

    Edit2: In this case(ActionEvent#getModifiers() (Java SE 9 & JDK 9)), should use ActionEvent.SHIFT_MASK instead of InputEvent.SHIFT_MASK

    • ActionEvent.SHIFT_MASK : 1
    • InputEvent.SHIFT_MASK : 1 @Deprecated(since=”9″)
    • InputEvent.SHIFT_DOWN_MASK : 64
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JFrame with a menu bar and a canvas covering all the
I have a bunch of projects in parallel subdirectories that all have etc/lighttpd.conf files.
I have a MFC dialog with 32 CComboBoxes on it that all have the
So I have a form with lots of controls that all have a tab
I have a JFrame that has a large number of changing child components. (Many
I have a JFrame that accepts top-level drops of files. However after a drop
I'm sure we all have received the wonderfully vague Object reference not set to
I have created a bunch of movie clips which all have similar names and
I have many emails coming in from different sources. they all have attachments, many
My Situation I have a N rectangles The rectangles all have the same shape

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.