Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JTextField;
- import java.sql.*;
- public class prog extends JFrame {
- //private JPanel contentPane;
- private panel contentPane;
- private JTextField textField;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- prog frame = new prog();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public prog() {
- setTitle("\u041F\u0440\u0435\u0434\u0441\u043A\u0430\u0437\u0430\u043D\u0438\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043E");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 523, 564);
- //contentPane = new JPanel();
- contentPane = new panel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- JLabel lblNewLabel = new JLabel("\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0438\u0442\u0435 \u043D\u0430 \u043C\u0430\u0433\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u043A\u0432\u0430\u0434\u0440\u0430\u0442...");
- lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18));
- lblNewLabel.setBounds(46, 23, 342, 23);
- contentPane.add(lblNewLabel);
- JLabel label = new JLabel("\u0412\u0433\u043B\u044F\u0434\u0438\u0442\u0435\u0441\u044C \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u0435..");
- label.setFont(new Font("Tahoma", Font.PLAIN, 15));
- label.setBounds(46, 58, 342, 23);
- contentPane.add(label);
- JLabel label_1 = new JLabel("\u041F\u043E\u0434\u0443\u043C\u0430\u0439\u0442\u0435 \u043E \u0442\u043E\u043C, \u0447\u0442\u043E \u0432\u044B \u0445\u043E\u0442\u0438\u0442\u0435...");
- label_1.setFont(new Font("Tahoma", Font.PLAIN, 17));
- label_1.setBounds(46, 365, 342, 23);
- contentPane.add(label_1);
- JButton btnNewButton = new JButton("\u0423\u0437\u043D\u0430\u0442\u044C");
- btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
- btnNewButton.setBounds(304, 399, 134, 23);
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- //Переменная типа - подключение
- Connection connect;
- try
- {
- String driverName = "com.mysql.jdbc.Driver";
- Class.forName(driverName);
- String serverName = "localhost";
- String mybase = "game";
- String url_ = "jdbc:mysql://"+serverName+"/"+mybase;
- //Имя пользователя
- String username = "root";
- String password = "";
- //Установление подключения к базе данных
- connect = DriverManager.getConnection(url_,username,password);
- }
- catch (Exception ex) {
- // TODO: handle exception
- }
- }
- });
- contentPane.add(btnNewButton);
- textField = new JTextField();
- textField.setBounds(23, 437, 457, 66);
- contentPane.add(textField);
- textField.setColumns(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement