Home > Back-end > Java how close the another class in a class of the window
Java how close the another class in a class of the window
Time:09-20
For help! I wrote a Java SQL login registration screen, a class to write the login page, another listen in the class, but after listening to how close the login interface in this class, they are not in a class can't call ah, Wrote a JFrame j is in the login screen=new JFrame (), but can't call in the next class the j, could you tell me how to shut down
CodePudding user response:
Pass j also to listening in class
CodePudding user response:
Why use listening to shut down, after the login process, just directly closed
To external closed, need to write a message interface, external classes send messages, let oneself perform closed window
CodePudding user response:
With the dispose () method to close the current window
CodePudding user response:
To achieve what you said actually GUI window control is not difficult, no matter you in the program there are several classes, can according to the business need and put them on the mutual connection, so as to achieve our business requirements,
From the window of A simple narrative can you know you are in A class directly (such as A) directly created A JFream framework object ACTS as A login window, and the other A class components (such as B) implementation of login to monitor movement function, actually you after call setup method and reality show the login window, the user input the information necessary to invoke A class B listening in logging method, if you want to control in A class B you created JFream instance (that is, the login window), as long as through execution call B type passed as A parameter on the login method as JFream object, After a successful login can operate it in the listening class B JFream object to shut it down, and of course how you don't want to call the login method as a parameter, just before the call log method JFream object monitored object attributes assigned to B (premise is have a class B JFream member attributes, namely login window), it is recommended to use the back of the way,
CodePudding user response:
Add, for the sake of more convenient operation, it is recommended that you create JFream login window JFream class hierarchy, although some small coupling, but easier to write programs