Results 1 to 2 of 2
  1. #1
    lemontree45 is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default accessing default generated private methods in Netbeans (in case of multiple classes


    I have created a form with two Radiobuttons using Netbeans. I got the default actionperformed method for these radiobuttons.

    1st class:

    Java Code:
    public int setbit;
     private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                   
    Now I want to check from another class whether this 'setbit' variable is 1 or not

    2nd class:

    Java Code:
    1stclass obj=new 1stclass();

    This actionperformed private method is called inside the private method initComponents. and since all of them are private I cannot get this value of 'selectbit' in the next class.

    Or is there any other easier way to see if this Radiobutton is pressed if so I have to do something in another class.

    any sort of help would be appreciated.


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: accessing default generated private methods in Netbeans (in case of multiple clas

    I'm confused at what you're trying to do. If you don't get any decent answers, could you clarify things a bit? Are you saying the "bit" variable will be set no matter if the radiobutton is selected or not? Or are you using the bit variable as a surrogate for checking if the radiobutton is selected? If the former, why not give the class that holds the radiobuttons public getter methods that allow other classes to check the state of the radiobuttons. Something like

    Java Code:
    public boolean isRadioButtonFooSelected() {
       return radioButtonFoo.isSelected();
    If this is not the case and you want the other class to check the state of the bit variable, then give it an associated public getter method.

    The other issue is when you want to check this information. If you want to have the other class check on the state of this class when the radiobutton has been pressed, then you will need to have that other class listen to the radiobutton by some means. Myself, I like to do this best with a controller class (look up Model-view-controller for more on this).

Similar Threads

  1. Multiple private methods
    By java4deepak in forum New To Java
    Replies: 4
    Last Post: 01-05-2011, 02:05 PM
  2. Default / package-private access
    By genkuro in forum New To Java
    Replies: 1
    Last Post: 12-30-2010, 07:08 AM
  3. Inheritance - accessing private variables
    By counterfox in forum New To Java
    Replies: 3
    Last Post: 04-26-2010, 02:21 AM
  4. [SOLVED] Accessing private constructor
    By piyu.sha in forum New To Java
    Replies: 2
    Last Post: 10-06-2008, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts