Search the Community
Showing results for tags 'managing jframe windows'.
-
Hey, im using NetBeans to make a simple GUI, that would connect to a mysql database. I followed some guides and managed to make something, but now i want to change some features and i dont know what to look for on google/youtube.. Ill try to explain what i need, maybe someone can help me with it or point me in the right direction on what i should be looking for. So, when i press 'Run Project' in NetBeans, 1st i get this: 1) I would like to put that info message window, where it says that connection to database is established, somewhere in the GUI, is that possible? After i press 'OK' on the info message window, i can then input my login/password and login into the databse, heres the screen: 2) Here the info message window says that the login information is correct, again, i would like to hide this info window so that it would display somewhere in the GUI and not as a pop-up window. After i press 'OK' on the login detail window, a new 'JFrame' opens up (witch i will fill in with other things that i need later), heres the screen: 3) The old 'Login form' window didnt dissapear, can i make it so the new 'JFrame' opens up and the login frame dissapears, or can i make it so that the new JFrame window would replace the login frame? Heres the code just in case: Settings for database, shows the 1st info message window (if connection was succesfull): public class mysqlconnect { Connection conn = null; public static Connection ConnectDb() { try{ Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://Database related stuff"); JOptionPane.showMessageDialog(null, "Prisijungimas pavyko"); return conn; }catch (Exception e) { JOptionPane.showMessageDialog(null, e); return null; } } } When i click the 'Login' button in the login frame, shows if login info was correct or not, also if correct opens new JFrame: private void cmdloginMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: String sql = "select * from Vartotojas where login = ? and password = ?"; try { pst = conn.prepareStatement(sql); pst.setString(1, txtusername.getText()); pst.setString(2, txtpassword.getText()); rs = pst.executeQuery(); if (rs.next()){ JOptionPane.showMessageDialog(null, "Prisijungimo duomenys teisingi"); QueryJFrame s = new QueryJFrame(); s.setVisible(true); } else JOptionPane.showMessageDialog(null, "Prisijungimo duomenys neteisingi"); } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } So yeah, these are my main problems at the moment, i dont really know what to type into google for help, so hoping someone here will clear things for me.. Also got some side questions: 4) After im done with this project, can i make it so it would be installable program? 5) If i can install it, can i make it start-up automatically every time i turn on the computer? (for example, like any antivirus program or even skype) 6) If i can install it, can it have its own icon near the clock in the bottom right corner? Thx and sorry if this was posted in the wrong seciton.