Advertisement
Guest User

Untitled

a guest
Jan 12th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. private void displayLoadDbScreen() {
  2. getContentPane().removeAll();
  3.  
  4. JLabel welcomeMsg = new JLabel("Database setup");
  5. welcomeMsg.setFont(new Font("Arial", Font.PLAIN, 18));
  6. welcomeMsg.setBounds(30,30, 400,20);
  7. add(welcomeMsg);
  8.  
  9. JLabel dbUrlMsg = new JLabel("Database URL: ");
  10. dbUrlMsg .setFont(new Font("Arial", Font.PLAIN, 12));
  11. dbUrlMsg .setBounds(30,75, 400,20);
  12. add(dbUrlMsg);
  13.  
  14. JTextField dbUrlInput = new JTextField("jdbc:mysql://localhost:3306");
  15. dbUrlInput.setBounds(150,71, 200,30);
  16. add(dbUrlInput);
  17.  
  18. JLabel userNameMsg = new JLabel("User name: ");
  19. userNameMsg.setFont(new Font("Arial", Font.PLAIN, 12));
  20. userNameMsg.setBounds(30,115, 400,20);
  21. add(userNameMsg);
  22.  
  23. JTextField userNameInput = new JTextField("root");
  24. userNameInput.setBounds(150,111, 200,30);
  25. add(userNameInput);
  26.  
  27. JLabel passwordMsg = new JLabel("Password: ");
  28. passwordMsg.setFont(new Font("Arial", Font.PLAIN, 12));
  29. passwordMsg.setBounds(30,155, 400,20);
  30. add(passwordMsg);
  31.  
  32. JPasswordField passwordInput = new JPasswordField ("");
  33. passwordInput.setBounds(150,151, 200,30);
  34. add(passwordInput);
  35.  
  36. JLabel dbNameMsg = new JLabel("Database name: ");
  37. dbNameMsg.setFont(new Font("Arial", Font.PLAIN, 12));
  38. dbNameMsg.setBounds(30,195, 400,20);
  39. add(dbNameMsg);
  40.  
  41. JTextField dbNameInput = new JTextField("quizzes");
  42. dbNameInput.setBounds(150,191, 200,30);
  43. add(dbNameInput);
  44.  
  45. JLabel errMsg = new JLabel("");
  46. errMsg.setFont(new Font("Arial", Font.PLAIN, 10));
  47. errMsg.setBounds(30,233, 400,10);
  48. errMsg.setForeground(new Color(255, 0, 0));
  49. add(errMsg);
  50.  
  51. JButton nextBtn = new JButton("next");
  52. nextBtn.setFont(new Font("Arial", Font.PLAIN, 11));
  53. nextBtn.setBounds(400,200,60, 30);
  54. nextBtn.addActionListener(ae -> {
  55. try {
  56. validateLoadDbInputs(dbUrlInput.getText(), userNameInput.getText(), new String(passwordInput.getPassword()), dbNameInput.getText());
  57. dbUrl_ = dbUrlInput.getText();
  58. dbUserName_ = userNameInput.getText();
  59. dbPassword_ = new String(passwordInput.getPassword());
  60. dbName_ = dbNameInput.getText();
  61. displaySettingsScreen();
  62. }
  63. catch(Exception e) {
  64. errMsg.setText(e.getMessage());
  65. repaint();
  66. }
  67. });
  68. add(nextBtn);
  69.  
  70. JLabel nextMsg = new JLabel("Press 'next' to continue.");
  71. nextMsg.setFont(new Font("Arial", Font.PLAIN, 10));
  72. nextMsg.setBounds(350,233, 120,10);
  73. add(nextMsg);
  74.  
  75. repaint();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement