1

I am new to Java GUI I deigned and window and menu item using java design tool.But when I want to create window for menu item say New contact I did not find an option to do that in event handler so I did it manually by coding it.But when I go to design part and click on New Contact it does not show the window I created via code.

Here is the screen shot of deign view -when I click on New Contact nothing happens.enter image description here

Now in the source code when I run it I get the window I coded enter image description here

Is there any possible way I can make it work in design part? I did not find any option to do it in Add Event Handler

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Box
  • 113
  • 12

1 Answers1

1
  1. You do not want a JFrame to show another JFrame -- that's a bad GUI design since it means that your application is actually two applications. Better to show a dialog window such as a JDialog. Please see The Use of Multiple JFrames, Good/Bad Practice?
  2. If you want to design a 2nd window, create a new Java program in NetBeans, one that creates this second window (again, better for it to be a JDialog, not a JPanel)
  3. Give it a constructor that allows passing in the parent window, and then pass that to the JDialog super constructor
  4. And then in your ActionListener code above, create a new object of this new program, passing in the current JFrame.

In the future, please post code as code-formatted text, not as an image, since this way we can copy, paste, compile and run it if we want, allowing us to better understand your code and your problem.

Community
  • 1
  • 1
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373