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

CodePudding user response:

reference 1st floor qybao response:
pass j also to listen class

Specific how to preach

CodePudding user response:

zen teacher class reference 4 floor response:
actually GUI window control to achieve what you said is not very hard, no matter you in the program there are several classes, can according to the business need and put them on the mutual relation, thus 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,

Excuse me, how will jframe object assigned to listen to class

CodePudding user response:

refer to the second floor tianfang response:
why use listening to shut down, after the login process, is directly closed

To external closed, need to write a message interface, external classes send messages, allow yourself to be the window to perform closed

I wanted to write a login after successful login window will be automatically closed and then jump to other pages, or that have been in the login window, could you tell me how to write ah interface should

CodePudding user response:

refer to 7th floor GDswag response:
Quote: zen teacher reference 4 floor classroom 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,

Excuse me how to set the jframe object assigned to listening class.
package com. The demo;
/* *
* user component (if required)
* @ author java_
*
*/
Public class User {

private String name;
private String password;

Public void elegantly-named setName (String name) {
this.name=name;
}

Public void setPassword (String password) {
Enclosing the password=password;

}

Public String getName () {
return name;
}

Public String getPassword () {
Return the password;
}

}

CodePudding user response:

refer to 7th floor GDswag response:
Quote: zen teacher reference 4 floor classroom 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,

Excuse me how to set the jframe object assigned to listening class.
package com. The demo;

The import javax.mail. Swing. JFrame;
/* *
* login to monitor simple implementation example, do not consider any multithreaded
* @ author java_
*
*/
Public class UserLoginListener {

Private JFrame loginWin;//login window JFrame component

Public User loginListening (String name, String password) {

A Boolean result=login (name, password);
If (result) {//login successful

User user=new User();
User. Elegantly-named setName (name);
The user. The setPassword (password);
/* close the login window (here did not release window, just hide, appropriate time to show) */
LoginWin. SetVisible (false);
Return the user;//return the logged in user (if the login window components need this object)
}
return null;//login failed,
}
Private Boolean login (String name, String password) {

/* login validation implementation logic */
return false;//
}

Public UserLoginListener () {

}
Public UserLoginListener (JFrame loginWin) {

Enclosing loginWin=loginWin;
}
Public void setLoginWin (JFrame loginWin) {
Enclosing loginWin=loginWin;
}
}

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related