Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JTextField not correctly updating
- connectButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- statusBar.setText("Connecting...");
- }
- }
- });
- connectButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Class.forName("com.mysql.jdbc.Driver");
- statusBar.setText("Connecting...");
- connection = DriverManager.getConnection("jdbc:mysql://" + database);
- }
- }
- });
- connectButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- statusBar.setText("Connecting...");
- new SwingWorker<Void, Void>() {
- protected Void doInBackground() {
- // Called on a background thread.
- connectToDatabase();
- return null;
- }
- protected void done() {
- // Called on Event Dispatch thread once connect routine has completed.
- try {
- get(); // Propagate any exceptions back to Event Dispatch thread.
- } catch (Exception ex) {
- ex.printStackTrace();
- JOptionPane.showMessageDialog(null,
- "Failed to connect: " + ex.getMessage(),
- "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- }.execute();
- }
- });
Add Comment
Please, Sign In to add comment