Advertisement
Guest User

Untitled

a guest
Jan 11th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. package pripojenidatabaze;
  8.  
  9. import java.awt.GridLayout;
  10. import static java.awt.SystemColor.text;
  11. import java.awt.event.ActionEvent;
  12. import java.sql.Connection;
  13. import java.sql.DriverManager;
  14. import java.sql.SQLException;
  15. import java.util.Properties;
  16. import javax.swing.JButton;
  17. import javax.swing.JFrame;
  18. import javax.swing.JOptionPane;
  19. import javax.swing.JTextField;
  20.  
  21. public class PripojeniDatabaze extends JFrame{
  22.  
  23. JButton tlacitko = new JButton("Stiskni mě!");
  24. JTextField text = new JTextField();
  25.  
  26. public PripojeniDatabaze()
  27. {
  28. this.initComponents();
  29. }
  30.  
  31. public static void main(String[] args) {
  32.  
  33. try{
  34. String host="jdbc:mysql://localhost:3306/";
  35. String uName="progoa";
  36. String uPass="progoauh";
  37.  
  38. Connection con = DriverManager.getConnection(host,uName,uPass);
  39. }
  40. catch (SQLException err){
  41. System.out.println(err.getMessage());
  42. }
  43. }
  44.  
  45. public void initComponents()
  46. {
  47. setTitle("Nové Okno");
  48. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  49.  
  50. this.setLayout(new GridLayout(1,2));
  51.  
  52. this.add(tlacitko);
  53. this.add(text);
  54.  
  55. tlacitko.addActionListener((ActionEvent e) -> {
  56. reakce();
  57. });
  58.  
  59.  
  60. this.pack();
  61.  
  62. }
  63.  
  64. private void reakce(){
  65.  
  66. JOptionPane.showMessageDialog(this,"Hurá!","Stisknuto",JOptionPane.INFORMATION_MESSAGE);
  67.  
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement