Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pripojenidatabaze;
- import java.awt.GridLayout;
- import static java.awt.SystemColor.text;
- import java.awt.event.ActionEvent;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.Properties;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JTextField;
- public class PripojeniDatabaze extends JFrame{
- JButton tlacitko = new JButton("Stiskni mě!");
- JTextField text = new JTextField();
- public PripojeniDatabaze()
- {
- this.initComponents();
- }
- public static void main(String[] args) {
- try{
- String host="jdbc:mysql://localhost:3306/";
- String uName="progoa";
- String uPass="progoauh";
- Connection con = DriverManager.getConnection(host,uName,uPass);
- }
- catch (SQLException err){
- System.out.println(err.getMessage());
- }
- }
- public void initComponents()
- {
- setTitle("Nové Okno");
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLayout(new GridLayout(1,2));
- this.add(tlacitko);
- this.add(text);
- tlacitko.addActionListener((ActionEvent e) -> {
- reakce();
- });
- this.pack();
- }
- private void reakce(){
- JOptionPane.showMessageDialog(this,"Hurá!","Stisknuto",JOptionPane.INFORMATION_MESSAGE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement