Jump to content

Open / CLose Forms

- - - - -

  • Please log in to reply
14 replies to this topic

#1
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
[SIZE=2]I have several forms created in java (Net beans) and one of them have a button. (simple example)

I want to open a new form when I click this button( new Form().show ) , but I want to hide the first one ( and the dispose dont work )

And also , when the second is closed, the fist is opened !!

suggestions?

Thanks, I really need this, please answers/SIZE]

#2
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Not sure what you mean by a form? Is it a window like a Frame or a Dialog?
One way to swap the GUI being shown in window from one panel to another panel is to use CardLayout.

Otherwise post a small, simple program that compiles, executes and shows the problem.

#3
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
form means a JFrame 'form' http://dl.dropbox.co...33652950/ss.jpg

#4
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Did you look at the CardLayout class? It allows you to easily change what is shown on a GUI.

#5
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
yes !! bu i want do it in code !!

example , click login button and the login panel hides and the new panel shows up ! in this new panel, i click, for example, change user, and this panel hides, and the login panel shows up again !!

#6
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Using CardLayout would be much easier.

Do you have code that shows what you want to do and that you are having problems with?
Or make a small simple program that compiles, executes and shows the problem and post that here.

#7
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
If you only hide a panel for a short time simple call setVisible(false) on the main frame, while you create and show the 2nd panel. When you're done with the 2nd panel, dispose() it, and setVisible(true) the first again.

#8
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts

Oh thanks ! ! setVisible(false) - of coursse !! thanks



#9
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
setVisible(false) doesnt work !!



String pass = JTPassword.getText();

        if (pass.equals("admin")) {

            JLErrado.setVisible(false);

            // if the in the texfield is correct, this jform shoul disappear and the other appear !!

            new LOGIN().setVisible(false); // dont work !! 

            new Desk().show();

        } else {

            JLErrado.setVisible(true);

        }


#10
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Can you make a small, simple program (SSCCE) that compiles, executes and shows your problem and post it here for testing?

#11
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
How can I make that ??

#12
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
One way is to Use an editor.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users