Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package extract;
- import java.sql.*;
- public class MainJFrame extends javax.swing.JFrame implements Runnable{
- public MainJFrame() {
- initComponents();
- }
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- ClientLabel = new javax.swing.JLabel();
- ClientField = new javax.swing.JTextField();
- ExtractButton = new javax.swing.JButton();
- UsernameLabel = new javax.swing.JLabel();
- PasswordLabel = new javax.swing.JLabel();
- UsernameField = new javax.swing.JTextField();
- PasswordField = new javax.swing.JPasswordField();
- MenuBar = new javax.swing.JMenuBar();
- FileMenu = new javax.swing.JMenu();
- ExitMenuItem = new javax.swing.JMenuItem();
- HelpMenu = new javax.swing.JMenu();
- AboutMenuItem = new javax.swing.JMenuItem();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("Data Extract");
- setResizable(false);
- ClientLabel.setText("Client Code(s):");
- ClientField.setText("Client1, Client2");
- ExtractButton.setText("Extract");
- ExtractButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- ExtractButtonActionPerformed(evt);
- }
- });
- UsernameLabel.setText("Username:");
- PasswordLabel.setText("Password:");
- FileMenu.setText("File");
- ExitMenuItem.setText("Exit");
- ExitMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- ExitMenuItemActionPerformed(evt);
- }
- });
- FileMenu.add(ExitMenuItem);
- MenuBar.add(FileMenu);
- HelpMenu.setText("Help");
- AboutMenuItem.setText("About");
- HelpMenu.add(AboutMenuItem);
- MenuBar.add(HelpMenu);
- setJMenuBar(MenuBar);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(ClientLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(221, 221, 221))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(ClientField, javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(UsernameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(UsernameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(PasswordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(ExtractButton)
- .addComponent(PasswordField, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
- .addContainerGap())))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(PasswordLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(PasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(32, 32, 32)
- .addComponent(ExtractButton))
- .addGroup(layout.createSequentialGroup()
- .addComponent(UsernameLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(UsernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(12, 12, 12)
- .addComponent(ClientLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(ClientField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void ExitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
- dispose();
- System.exit(0);
- }
- private void ExtractButtonActionPerformed(java.awt.event.ActionEvent evt) {
- String clients = ClientField.getText();
- String user = UsernameField.getText();
- char[] char_pass = PasswordField.getPassword();
- String pass = new String(char_pass);
- DB db = new DB(user, pass);
- db.setClients(clients);
- try {
- db.connect();
- db.testSQL();
- db.close();
- } catch (ClassNotFoundException e) {
- System.out.println(e.getException());
- } catch (SQLException e) {
- System.out.println(e.getErrorCode());
- }
- }
- public void run() {
- this.setVisible(true);
- }
- // Variables declaration - do not modify
- private javax.swing.JMenuItem AboutMenuItem;
- private javax.swing.JTextField ClientField;
- private javax.swing.JLabel ClientLabel;
- private javax.swing.JMenuItem ExitMenuItem;
- private javax.swing.JButton ExtractButton;
- private javax.swing.JMenu FileMenu;
- private javax.swing.JMenu HelpMenu;
- private javax.swing.JMenuBar MenuBar;
- private javax.swing.JPasswordField PasswordField;
- private javax.swing.JLabel PasswordLabel;
- private javax.swing.JTextField UsernameField;
- private javax.swing.JLabel UsernameLabel;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement