CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Posts
    6

    Question Moron Trying To Open A Window

    I would like to open a window that I have designed in the Netbeans GUI editor (I forget the name of it).
    The window is called ProjectTaskWindow.java

    I have a feeling I should use the setVisible property, although I don't know how to do this.

    I would like it to be opened from a menu item.

    Than you a lot.

    I looked in Java for dummies (yes I am that crap) but I couldn't find anything useful.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Moron Trying To Open A Window

    setVisible is a method that you call to set the window's visible state ie you pass in true to make it visible and false to hide it.
    Code:
     
    // show the window
    myWindow.setVisible(true);
     
    ...
     
    // hide the window
    myWindow.setVisible(false);

  3. #3
    Join Date
    Dec 2009
    Posts
    6

    Exclamation Re: Moron Trying To Open A Window

    Thank you.

    Unfortunately, unless I've been particularly stupid, my theory that getVisible() was the way to do it was wrong.

    I implemented it, first I had several issues with the symbol not being found.

    Message: symbol not found
    . method setVisible(boolean)
    . Location: class.ProjectTaskWindow

    After this, I created at getVisible method on ProjectTaskWindow (at the compiler's suggestion).

    The created method appeared as follows:

    public static void setVisible(boolean b) {
    throw new UnsupportedOperationException("Not yet implemented");
    }
    Which I know is completely wrong logically. I am now back where I started.

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Moron Trying To Open A Window

    setVisible(..) is a method defined by java.awt.Window so any class that extends this class such as JFrame, JDialog etc will have this method. If your class doesn't extend java.awt.Window then this method won't work for you unless you code it yourself. However, without more info on what you are trying to do it's hard to give detailed advice. Can you show enough of your code to show the problem (in code tags please).

  5. #5
    Join Date
    Dec 2009
    Posts
    6

    Post Re: Moron Trying To Open A Window

    The program I am writing is intended to keep track of time spent on various tasks and projects and upload it to a MySQL database, as such, the project is called TimeKeeping.

    I have two main windows:
    TimeKeepingView.java - The window which will be used for inputting data about what the user is doing at that time.

    ProjectTaskWindow.java - The window which will be used to set the lists of projects and tasks.

    I would like ProjectTaskWindow to be openable from a menu item in a menu bar at the top of TimeKeepingView. I have already added the menu item

    A call is made to a method in TimeKeepingApp by the menu item.

    In TimeKeepingApp.java:
    Code:
     @Action
        public void ShowProjectTaskWindow() {
            DisplayProjectTaskWindow();
        }
    In ProjectTaskWindow.java
    Code:
        public void DisplayProjectTaskWindow(){
            setVisible();
        }
    Also in ProjectTaskWindow.java
    Code:
        private void setVisible() {
            throw new UnsupportedOperationException("Not yet implemented");
        }
    Is this information sufficient?

    Thank you so much for your time and help.

  6. #6
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Moron Trying To Open A Window

    All windows have a setVisible method that takes a boolean parameter to show or hide the window. You should not override or overload that method unless you know what you're doing. In this case, you don't need to. Just call setVisible(true) on the window instance you want to show, and setVisible(false) when you want to hide it.

    If calling these methods doesn't seem to work, the windows probably aren't set up properly.

    Teachers open the door, but you must enter by yourself...
    Chinese proverb
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured