Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Getting rid of deprecation

  • 23-02-2006 3:22pm
    #1
    Registered Users, Registered Users 2 Posts: 1,144 ✭✭✭


    i've been asked to remove the deprecated methods from one of our projects (written in java). I have a query: It says to replace show() and hide() methods with setVisible(true) or setVisible(false). But if hide or show are method declarations in one file, it doesnt let me have 2 setVisible methods in the one java class. Does anyone know how i'd set these methods up so thet dont give me any warnings?

    public void show() //have to replace this with setVisible
    {
    super.setVisible(true);
    }

    public void hide() // Have to also replace this with setVisible
    {
    setVisible(false);
    }
    }


Comments

  • Registered Users, Registered Users 2 Posts: 21,084 ✭✭✭✭Stark


    There's already a setVisible(boolean flag) method in the super class? Then you don't need to do anything other than remove show() and hide() from your implementation.

    PS: If you were to add an option for setVisible(true) or setVisible(false) into your class, then you don't put that in verbatim, you put in setVisible(boolean flag) ;) Otherwise trying to put in a method that accepted something like a decimal value could get very messy :D


  • Closed Accounts Posts: 36 l337


    why would you want 2 setVisible() in one class?
    public void setVisible(boolean b) {
    if (b==true) {
    // stuff
    } else {
    //stuff
    }
    }

    If there is a setVisible() in a superclass you may in fact need to override it in any subclass, depending on what the subclass does eg
    Superclass -> drawHead, superclass.setVisible(false) {//remove head}
    Subvclass -> drawHeadAndShoulders subclass.setVisible(false) {//super.setVisible(false); this.removeShoulders()}


    apologies if this doesn't make any sense


  • Registered Users, Registered Users 2 Posts: 1,144 ✭✭✭gracehopper


    l337 wrote:
    apologies if this doesn't make any sense

    No it does, i've had a look at the sun tutorial and my Net Beans manual i understand now. Cheers for the help and to Stark aswell

    nice one!


Advertisement