esoe
3 years ago
7 changed files with 199 additions and 59 deletions
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
public class Access { |
||||
private String link; |
||||
private String login; |
||||
private String password; |
||||
/** |
||||
* @param link the link to set |
||||
*/ |
||||
public void setLink(String link) { |
||||
this.link = link; |
||||
} |
||||
/** |
||||
* @return the link |
||||
*/ |
||||
public String getLink() { |
||||
return link; |
||||
} |
||||
/** |
||||
* @param login the login to set |
||||
*/ |
||||
public void setLogin(String login) { |
||||
this.login = login; |
||||
} |
||||
/** |
||||
* @return the login |
||||
*/ |
||||
public String getLogin() { |
||||
return login; |
||||
} |
||||
/** |
||||
* @param password the password to set |
||||
*/ |
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
/** |
||||
* @return the password |
||||
*/ |
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Color; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JPasswordField; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.WindowConstants; |
||||
import javax.swing.border.LineBorder; |
||||
import javax.swing.border.TitledBorder; |
||||
|
||||
//import ru.egspt.moodle.events.ConnactionListener;
|
||||
//import ru.egspt.moodle.events.DisconnectionListener;
|
||||
|
||||
public class AccessPane extends JPanel { |
||||
private JLabel loginLabel = new JLabel("Имя пользователя: "); |
||||
private JTextField loginField = new JTextField(25); |
||||
private JLabel passLabel = new JLabel("Пароль: "); |
||||
private JPasswordField passField = new JPasswordField(25); |
||||
private JLabel linkLabel = new JLabel("Адрес сервера: "); |
||||
private JTextField linkField = new JTextField(25); |
||||
private JButton connButton = new JButton("Подключиться"); |
||||
private JButton DisconnButton = new JButton("Отключиться"); |
||||
|
||||
public AccessPane(Base base){ |
||||
loginField.setText("esoe");//значения по умолчанию
|
||||
linkField.setText("www.egspt.ru");//значения по умолчанию
|
||||
this.add(loginLabel); |
||||
this.add(loginField); |
||||
this.add(passLabel); |
||||
this.add(passField); |
||||
this.add(linkLabel); |
||||
this.add(linkField); |
||||
this.add(connButton); |
||||
//настройка кнопки connButton
|
||||
connButton.addActionListener(e -> BaseControls.ConnectToServer(base, this)); |
||||
this.add(DisconnButton); |
||||
DisconnButton.addActionListener(e -> BaseControls.DisconnectFromServer(base)); |
||||
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "connection to mysql", TitledBorder.CENTER, TitledBorder.CENTER); |
||||
this.setBorder(border); |
||||
//this.setBorder(BorderFactory.createTitledBorder("аккаунт сервера базы данных"));
|
||||
this.setSize(320, 240); |
||||
this.setVisible(true); |
||||
} |
||||
/** |
||||
* @return the loginField |
||||
*/ |
||||
public JTextField getLoginField() { |
||||
return loginField; |
||||
} |
||||
/** |
||||
* @return the passField |
||||
*/ |
||||
public JPasswordField getPassField() { |
||||
return passField; |
||||
} |
||||
/** |
||||
* @return the urlField |
||||
*/ |
||||
public JTextField getLinkField() { |
||||
return linkField; |
||||
} |
||||
public static void main( String[] args ){ |
||||
Base base = new Base(); |
||||
//Data data;
|
||||
System.out.println( "Проверка работоспособности класса Account ..." ); |
||||
JFrame mainframe = new JFrame("connaction"); |
||||
AccessPane acc = new AccessPane(base); |
||||
mainframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
||||
mainframe.add(acc); |
||||
mainframe.setSize(320, 240); |
||||
mainframe.setVisible(true); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
|
||||
public class BaseControls { |
||||
//
|
||||
public static void ConnectToServer(Base base, AccessPane accessPane){ |
||||
System.out.println("Инициировано событие ConnectToServer ..."); |
||||
String link = accessPane.getLinkField().getText(); |
||||
base.getAccess().setLink(link); |
||||
String login = accessPane.getLoginField().getText(); |
||||
base.getAccess().setLogin(login); |
||||
String password = String.valueOf(accessPane.getPassField().getPassword()); |
||||
base.getAccess().setPassword(password); |
||||
base.connect();//подключиться к базе
|
||||
} |
||||
public static void DisconnectFromServer(Base base){ |
||||
System.out.println("Инициировано событие DisconnectFromServer ..."); |
||||
base.disconnect(); |
||||
} |
||||
} |
Loading…
Reference in new issue