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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:08:53+00:00 2026-05-16T03:08:53+00:00

Okay, this is a bit messy: I’m using Netbeans, and I have a main

  • 0

Okay, this is a bit messy:

I’m using Netbeans, and I have a main class called ParameterUI. (This is a GUI)
This class has a few sliders on its GUI, and since these are private, I have a method called getBounds(). I don’t want to clutter up my GUI, and so essentially all the important methods for calculating stuff are in another class called Structure. So ParameterUI calls a method in Structure, which calls another few methods inside itself, and one of these calls getBounds.

The problem is that getBounds can’t be static, but I can’t call it if it isn’t.

In ParameterUI.class :

public int[] getBounds () {
    int[] bounds = new int[2];
    bounds[0] = jSlider2.getMinimum();
    bounds[1] = jSlider2.getMaximum();
    return bounds;
}

In Structure.class :

private static void myMethod (Graphics g, double[] planet, long mass) {
    int[] bounds = ParameterUI.getBounds(); //<-- doesn't work
}

Making myMethod non-static doesn’t seem to help either.
I’m afraid that while I know the basics about static vs. non-static, I haven’t been programming with classes etc. for that long.

Edit: Essentially, I know what the problem is, and I’m looking for a better way to solve it.

  • 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-16T03:08:54+00:00Added an answer on May 16, 2026 at 3:08 am

    Pass the ParameterUI instance to the static method

    private static void myMethod (ParameterUI param, Graphics g, double[] planet, long mass) {
        int[] bounds = param.getBounds(); //<-- doesn't work
    }
    

    However you may want to reconsider a design where you are calling into static methods of other classes in order to calculate things about the first class. This suggests that all of the logic necessary for your UI class is not contained in it, and public static methods lead to hard to test code.

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

Sidebar

Related Questions

Okay so I have defined my DSNavigationManager class and it has a property called
I have a bit of problem with this. I have a class A which
Okay, if I have a html document that looks a bit like this: <div
Okay this is a real headscratcher. I have an application which calls a web
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay, this is just a crazy idea I have. Stack Overflow looks very structured
Okay this is a bit of a noobish question, but I ran across this
Okay this one may be a bit out from left field, but I'm going
Okay so this query should be easy but I'm having a bit of difficult.
Okay so I have two import pieces of code involved in this. This first

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.