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 8185213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:46:09+00:00 2026-06-07T01:46:09+00:00

class Scroll { static boolean up; static boolean down; public static void scroll(boolean direction)

  • 0
class Scroll {
    static boolean up;
    static boolean down;
    public static void scroll(boolean direction) {
        if (/* ... */) {
            System.out.println("UP");
        }
        else {
            System.out.println("DOWN");
    }
}

public class Test2 {
    public static void main(String[] args) {
        Scroll.scroll(Scroll.up);
    }
}

How can I check which field has function been called with – with Scroll.up or Scroll.down? I know that in above code I could get same effect in other way, but it’s simplified code with essence of my problem.

  • 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-07T01:46:10+00:00Added an answer on June 7, 2026 at 1:46 am

    If the only choices are up or down, you can rename direction as up and then:

    if (up) {
        // Up
    }
    else {
        // Down
    }
    

    If there are more directions (left and right, for instance), or even if not really, this is where enum is handy:

    enum Direction {
        Up,
        Down,
        Left,
        Right
    }
    

    Then use that in your code, possibly with a switch:

    switch (direction) {
        case Direction.Up:
            // ...
            break;
        case Direction.Down:
            // ...
            break;
        case Direction.Left:
            // ...
            break;
        case Direction.Right:
            // ...
            break;
    }
    

    More about enums.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class X { int i; public: X() { i = 0; } void set(int
my custom verticalfieldmanger public class Custom_TopField extends VerticalFieldManager { private static final int FIELD_HEIGHT
I create my own class which extend ScrollView but scroll bar disapear. How Can
class Widget; std::vector< std::shared_ptr<Widget> > container class Criterium { public: bool operator()(const Widget& left,
Class 1 private void checkDuplicateCustomer(BulkCustomerVO bulkCustomerVO) { PagedDuplicateCustomerVO duplicateCustomerVO = new PagedDuplicateCustomerVO(); duplicateCustomerVO.setCustomer(bulkCustomerVO.getCustomerVO()); duplicateCustomerVO
To make a table scroll with a static header I added the following: tbody.scrollContent
I have this class as an example of my problem. The scrollpane doesn't scroll,
import java.awt.event.*; import java.io.File; import javax.swing.*; public class Launch extends JFrame implements ActionListener {
Here is the scrollbar class in question: http://jsfiddle.net/brandondurham/6SUyM/3/ Currently the height of the scroll
I've just came across this example : Scroll down to the bottom of the

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.