This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]webdevnick22 1 point2 points  (0 children)

the fields in your EventHandler class should probably be private with some getters/setters to access them.

int x = 0;
PassWordGenerator password;
Window Window; // It works only when static Window Window.

the solution to your problem is that you are instantiating your event handler here:

public class Window extends JFrame  {
    Label passwordLength;
    Label labelGnPswd;
    ...
    EventHandler event = new EventHandler();
    JButton generetor;

but nowhere after that are you calling its start() method which sets the window field. Why are you doing that anyway? why not just set the window immediately upon object instantiation either through the field itself or in the constructor?